Return Largest Numbers in Arrays - Code sorts numbers in new array

Tell us what’s happening:
The code almost works but i am obviously missing something.

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return an array.
**THIS RETURNS [5, 27, 39, 1001]** INSTEAD largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27,5,39,1001].
largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) should return [9, 35, 97, 1000000].

it seems to sort the numbers for a reason i find muself unable to understand, any help appreciated :smiley:

Your code so far

function largestOfFour(arr) {
  var num = "" ;
  var newArr = [];
  for (var i = 0; i < arr.length; i++){
    for (var x = 0; x < arr[i].length; x++){
        if (num < arr[i][x]){
          num = arr[i][x];
        } 
      }newArr.push(num);
  }return newArr;
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:

THANK YOU!

That was of course correct, resetting num between the outer and inner loop did the trick.