Ad
Code
Diff
  • const findMax = arr => arr.reduce((a, c) => c > a ? c : a, -Infinity);
    
    • function findMax(arr) {
    • max = arr[0];
    • for (i = 0; i<arr.length; i++){
    • if (arr[i] > max) {
    • max = arr[i]
    • }
    • }
    • return max
    • }
    • const findMax = arr => arr.reduce((a, c) => c > a ? c : a, -Infinity);