function largestOfFour(arr) {
var newArray = [];
for(var i =0; i <=arr.length-1; i++){
console.log(arr[i]);
newArray[i] = Math.max(arr[i]);
Edited: In order to add values to the array, I'd suggest using the push methodn. As in: NewArray.push(Math.max(...sub[i])); or newarray.push(math.max.apply(null, sub[i]). An alternative is alocating, when declarating the array, the size it will take: Var newArray = new Array(arr.length); There's this new spread operator (...) in javascript !