I was able to solve this problem with just a for loop, but I need some explanation

In each iteration:

...arr[i] // unpack an element (,which itself is an array) of arr, … is the spread sytax
//so for i=0, you get the list: 4, 5, 1, 3
Math.max(...arr[i]) // returns the maximum of the list above, i.e. 5 when i=0
largestNumbers.push(Math.max(...arr[i])); //Add the maximum (i.e. 5 when i=0) returned from the last step to the end of the array called largestNumbers, thus the result.

Hope that helps.

2 Likes