function largestOfFour(arr) {
var newArray = [];
for(var i =0; i <=arr.length-1; i++){
console.log(arr[i]);
newArray[i] = Math.max(arr[i]);
}
console.log(newArray);
// You can do this!
return newArray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
So I do not understand why I am getting NaN
even though i have provided an argument within my math.max
function. In the console.log within my for loop, i get each array within the main array to display. Meaning if I use the same arr[i]
within the max function, it should give me the max of that sub Array.