Tell us what’s happening:
Can someone explain to me why doesn’t “let biggestNum = 0” work. Is it due to the nested array? I have used it with simple arrays and it worked while here it doesn’t pass the last test.
Your code so far
function largestOfFour(arr) {
// You can do this!
let numArray = [];
for (let i = 0; i < arr.length; i++) {
let biggestNum = arr[i][0];
// why doesn't "let biggestNum = 0" work
// is it because it is a nested array?
for (let j = 0; j < arr[i].length; j++){
if (arr[i][j] > biggestNum) {
biggestNum = arr[i][j];
}
}
numArray.push(biggestNum);
}
return numArray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
.
Link to the challenge: