Tell us what’s happening:
Hello, why would this code function when called with [[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]] return 25,48,21,0 which cannot be found anywhere instead of 25, 7, 34, 48 which is a close match ?
Your code so far
function largestOfFour(arr) {
// You can do this!
var result = [];
for (let i=0; i < arr.length; i++) {
var largest = 0;
for (var ir=0; ir < arr[i].length; ir++) {
if (arr[i][ir] > largest) {
largest = arr[i][ir];
}
}
result[i] = largest;
}
return result;
}
console.log(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
.
Link to the challenge: