Tell us what’s happening:
My code works but it still doesn’t pass the test. What’s wrong with it?
Your code so far
let newarr=[];
let highNo=-Infinity; //Number.NEGATIVE_INFINITY
function largestOfFour(arr) {
for (let i =0; i<arr.length; i++){
for (let j=0; j<arr[i].length; j++){
if (arr[i][j]>highNo){
highNo=arr[i][j];
}
}
newarr.push(highNo);
highNo=Number.NEGATIVE_INFINITY;
//console.log(lowNo);
}
return newarr;
}
console.log(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36
.
Link to the challenge: