Your current approach is not going to work and there is a simpler way to do this.
I would suggest resetting the lesson.
If you are going to use the nested for loop approach you only need 1 if statement.
Not 4.
Slowly walk through the logic of this problem and see if you can solve this with just 1 statement.
You don’t need 4 variables all initialized to 0.
You just need one variable inside the for loop that will keep track of the largest num of each sub array.
Also, you don’t want to initialize this variable with 0.
reason being is because some of the sub arrays have negative numbers and you have to account for that.
Then you can push that largest num to the new arr.
function largestOfFour(arr) {
//create new empty arr
for (let i = 0; arr.length > i; i++) {
//largest num variable goes here
for (let j = 0; 4 > j; j++) {
//condition goes here
}
//add largest num to new arr
}
//return new arr
}
Try to slowly walk through the logic and implement an easier approach to the problem than your current code.