Ad
Code
Diff
  • const findMax = (arr) => Math.max(...arr)
    
    • function findMax(arr, max = -Infinity, i = 0) {
    • if (i > arr.length-1) return max
    • if (arr[i] > max) {
    • max = arr[i]
    • }
    • return findMax(arr,max, i +1)
    • }
    • const findMax = (arr) => Math.max(...arr)