Largest numbers in arrays function

Tell us what’s happening:
This solution seems to be working somehow, but it doesn’t pass 3 of 4 tests, any help?

  **Your code so far**

let maxArray = [];
function largestOfFour(arr) {
for (let i = 0; i < arr.length; i++) {
  maxArray.push(Math.max(...arr[i]));
}
return maxArray;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);

Link to the challenge:

This is a global variable. What happens if you run your function twice in a row?

2 Likes

Oh, now I see what’s the problem, thank you!

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.