Largest Number in Arrays

why does this code not work am i missing something i looked at several ways of completing this code but i am most familiar with FOR loops. I followed instructions as best as i could yet the code won’t pass any information will be greatly appreciated. If Possible please explain in prose as much as possible as i relate to that more than abstract concepts.

Your code so far


function largestOfFour(arr) {
var biggestNumber = [0,0,0,0];

  for (var subArray = 0; subArray < arr.length; subArray++) {

    for (var subIndex = 0; subIndex < arr[subArray].length; subIndex++) {

      if (arr [subArray][subIndex] > biggestNumber[subArray]) {

        biggestNumber[subArray] = arr[subArray][subIndex];
      }
    }
  }
  return biggestNumber;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:

Your code checks if the number is larger than 0, but this is going to fail is for example you have [-2, -10, -4, -16]. The biggest number there would be -2, but in your code you would record the biggest number as 0. On the inner loop, you’re iterating through each inner array. Maybe look at setting the first number as largest, then if the next one is larger, replace it with that and so on?