Return Largest Numbers in Arrays - code neatness

Tell us what’s happening:
Hello,

actually, I find out the solution of this assignment. Anyway, I’ve noticed that my solutions are usually different than suggested in “Get a hint” section. Should I be worried? My code works, but those seem to be more “neat”. Is this '‘neatness’ part important in front-end job? Or it’s mostly about finding the solution and problems resolving?

Your code so far

function largestOfFour(arr) {
  // You can do this!
  for (i=0; i<arr.length; i++) {
    arr[i] = arr[i].sort(function(a,b) {
      return b-a;
    });
  }
  
  var newArr = [];
  for (i=0; i<arr.length; i++) {
    newArr.push(arr[i][0]);
  }
  
  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 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36.

Link to the challenge:

Don’t worry if you take different paths to the solution for now. I answered a question like this just the other day, and the answer applies to your question too: Chunky Monkey - Very different solution

1 Like