Your code reassigns the name newArray to an empty array on each iteration, and returns a newly assigned value at the end of the iteration but never does anything with the returned value.
You probably want something like.
function largestOfFour(arr) {
var theMaxes = [];
for(var i=0,j=arr.length;i<j;i++) {
theMaxes.push(Math.max.apply(null, arr[i])); //Add to array that exists outside of for-loop.
}
return theMaxes;
}
I’m on it since this morning, trying to find what’s wrong, I think i’ve not understood yet how “for loops” works.
In your solution everything is ok, you just have to change “j++” by “i++” and it’s ok!