Hi guys, I was able to get all test cases correct except for the last one which included and array with all negative numbers. This is my current code:
function largestOfFour(arr) {
let finalArray = [];
for(let i = 0; i < arr.length; i++){
let num = 0;
for(let x = 0; x < arr[i].length; x++){
if(arr[i][x] > num){
num = arr[i][x]
}
}
finalArray.push(num)
}
return finalArray;
}
I just can’t seem to find a way to quantify and keep track of the “greatest” of the negative numbers in an array.