$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #122

Which fix removes the bug?

const out = rows
  .filter((r) => r.ok)
  .map((r) => r.v)
  .sort()
  .slice(0, 3);
  1. Sort numerically with (a, b) => a - b
  2. Sort numerically with (a, b) => a > b
  3. Move .slice(0, 3) before the .sort()
  4. Replace .filter with .flatMap here
The default sort compares as strings, so the top three are wrong for numbers.
Play Problem Solving ▸