Hola Coders,
I got stuck in the “Largest Numbers in Arrays” challenge. My code passed two of the tests. But in one of them, it repeats one of the largest number in the sub-array. Any tips/recommendations to correct this problem? ps:i know i can find a solution very easy on google, but i want to solve it by myself and a little help
function largestOfFour(arr) {
// You can do this!
var count=0;
var arrNew=[];
for(var i=0; i< arr.length;i++){
for(var j=0; j<arr[i].length;j++){
if(count < arr[i][j]){
count=arr[i][j];
}
}
arrNew.push(count);
}
return arrNew;
}
//2ºTEST
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);