Challenge 17 - Sometimes the shortest code isn't the best code


#1

This one-line solution does the job well enough. But have a closer look and see if you can identify where it really isn’t the best solution. This is an example to demonstrate that short code isn’t always the best code.

I removed a small part in this code as to not reveal the actual solution.

function shipReport(){
  return [allShips().sort()[],allShips().sort().pop()];
}

#2
let ships = allShips();
return [ships.shift(), ships.pop()];