Return Largest Numbers in Arrays help please

Tell us what’s happening:

Your code so far


function largestOfFour(arr) {
  // You can do this!
  var answer = [];
  for ( var i = 0; i < arr.length; i++) {
     var biggestNumber = 0;
     for ( var j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > biggestNumber) {
        biggestNumber = arr[i][j];
      }
    }
    answer[i] = biggestNumber;
  }
  return arr[i][j];
}

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_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays

1 Like

So close! You have all the logic correct but check one more time what you are returning.

You are saving numbers into somewhere else.

1 Like

You have an other thing to consider… what happens when the biggest number is negative?