function largestOfFour(arr) {
var str=[];
for(var i=0; i<arr.length; i++){
var maxNum = 0;
for(var j=0; j<arr[i].length; j++){
if(arr[i][j]>maxNum){
maxNum = arr[i][j];
} else if(arr[i][j]<0){
var minNum = arr[i][j];
if(arr[i][j] >= minNum){
maxNum = arr[i][j];
}
}
}
str.push(maxNum);
}
return str;
}
console.log(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])); //returns [5, 27, 39, 1001]
console.log(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])) // returns [25,48,21,-10]
In the last function call It should return [25, 48, 21, -3]
Can anyone correct the above code to find the largest number.