Return Largest Numbers in Arrays(What do I do for the negative integers?)

Tell us what’s happening:

Your code so far


function largestOfFour(arr) {
  // You can do this!

  var newArray = [0,0,0,0];
    for(var i = 0;i<arr.length;i++){
         for(var j =0;j<arr[i].length;j++){
            if(arr[i][j] > newArray[i]){
                newArray[i] = arr[i][j]; 
               }
           }
       }
   
  return newArray;
}

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

You’re setting up newArray as [0,0,0,0], it can just be be []; for each array, you can push the first value, then loop through and check subsequent values to see if they’re >