Please can somone please help my why it is not working?

Tell us what’s happening:

I am really stuck with this, please explain for me what I am doing wrong?!

Your code so far


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

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

It looks like you’re returning too early.

Look at this line:

return result[i] =largestNum;

Try to console.log and see what your function is returning.