Return Largest Numbers in Arrays(doesn't work )

Return Largest Numbers in Arrays(doesn't work )
0.0 0

#1

Tell us what’s happening:
I entered the code in another project and it worked there, but run test doesnt work

Your code so far

function largestOfFour(arr) {
  // You can do this!
  if(arr[0]>0)
  return arr;
  var g = arr[0];
  g.reduce(function(prevv,currv){
    return prevv>currv?prevv:currv;
  });
  arr.shift().push(g);
  largestOfFour(arr);
}

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:


#2

The above code does not change g. reduce returns a new array.

Also, the following is not doing what you think it is doing.

arr.shift().push(g);

You need to debug by putting some console.log statements at various places to see the values of certain variables before and after certain blocks of code.