Hey there, I am not sure why my code is not working. Actually it passes 3/4 tests. Only for the last one it says, that the test is not passed. Can you please help?
This is my code:
function largestOfFour(arr) {
let largestNumbers = [];
for (let i=0; i<arr.length; i++) {
let maxnumber = 0;
for (let ii=0; ii<arr[i].length; ii++) {
if (arr[i][ii] > maxnumber) {maxnumber = arr[i][ii]};
}
largestNumbers.push(maxnumber);
}
return largestNumbers;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
The only error-message that I am getting is:
largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]) should return [25, 48, 21, -3].
Can you please help? I dont know what is wrong with my code. Many thanks
Official Solution