Ad
Code
Diff
  • import java.util.*;
    
    public class Kata {
      
        public static int findMax(int[] my_array) {
            return Arrays.stream(my_array).max().getAsInt();
        }
      
    }
    • import java.util.*;
    • public class Kata {
    • public static int findMax(int[] my_array) {
    • // Write a method that returns the largest integer in the list.
    • // You can assume that the list has at least one element.
    • Arrays.sort(my_array);
    • return (my_array[my_array.length-1]);
    • return Arrays.stream(my_array).max().getAsInt();
    • }
    • }
Code
Diff
  • function removeEveryThird(str) {
        return str.split('').filter((_, i) => i === 0 || i % 3 !== 0).join('');
    }
    
    • function removeEveryThird(str) {
    • return (str[0] || '') + str
    • .slice(1)
    • .replace(/(..)./g, '$1')
    • }
    • return str.split('').filter((_, i) => i === 0 || i % 3 !== 0).join('');
    • }
Code
Diff
  • function revstr(str) {
        return str.split('').reverse().join('');
    }
    • const revstr = str => [...str].reverse().join``
    • function revstr(str) {
    • return str.split('').reverse().join('');
    • }