Return Largest Numbers in Arrays (sensible place)

Hi, coders!
I need help to understand, is my code good enough? and if not, what is it’s sensible place? why it’s bad from practice point of view?

Your code so far

function largestOfFour(arr) {
  // You can do this!
  var newArr =[];
  var final;
  var pushed;
  var separatedArr; 
  var sorted;
  for (var i = 0; i < arr.length; i++){
    separatedArr = arr[i].sort(function (a, b) {
      if (b > a){return b;}       
    });
    sorted = separatedArr.splice(0, 1);
    pushed = newArr.push(sorted);
    final = newArr.reduce(function(flat, current) {
    return flat.concat(current);
    }, []);
    
    console.log(final);
  }
  return final;
 
}

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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:

I’d say if the code works then its probably “good enough”.

hah):grinning: it’s not enough if i want to be better!

You might find the hint section for an exercise quite helpful. Even after you’ve found a solution check it out and see what FCC recommends.

great idea, thanks! I’ll check the fcc solution’s way

thats what I needed! Thank you very much!!! The reason, why I did so many extra steps, because of I don’t understand how exactly to use push() etc. When I try to apply them, the messages like “… is not a function” a little bit overwhelming me. So I’ve tryed to split solvation on little steps (and as you see, made so many steps, so even forget remove some extra of them))). Thanks for your help!