I was working through the algorithm Return Largest Numbers in Arrays and I got the solution, but I was wondering if the way I attacked the problem is correct. Is part of solving these challenges figuring a way to get the solution from researching online? Obviously not copying and pasting, but to look up methods and functions on MDN appropriate?

For instance, this was my code to solve the problem:

function largestOfFour(arr) {

// You can do this!

for(var i=0; i<arr.length; i++) {

arr[i]= Math.max.apply(null, arr[i]);

}

return arr;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

I assumed there was something related to Math.max() , so I googled it and read on how to use it in MDN. Is what I did a valid way to solve this problem? Or does FCC want us to reinvent the wheel and figure out how to solve it by what I would assume go through each array and compare the values within the arrays?

Thanks in advance!