Stuck in Return Largest Number in Array


Hello, I’m trying to resolve the Return Largest Numbers in Arrays algorithm challenge with this:

   /* jshint esversion: 6 */
    function largestOfFour(arr) {
      var max=[];
      for(var i=0; i<arr.length; i++){
        for(var j=0; j<arr[i].length; j++){
      return max;

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


And it, in fact, returns the largest number for each array but four times, I’m guessing because of the length of the outermost array. So I would like to know why is this happening and what I’m doing wrong, thank you.


Got this answered in less than ten minutes in Stack Overflow. If anyone’s interested, I didn’t need the second loop, because Math.max takes the whole array. This solution, however, is not accepted by the editor for some reason.