Which fix removes the bug?
const out = rows .filter((r) => r.ok) .map((r) => r.v) .sort() .slice(0, 3);
- Sort numerically with
(a, b) => a - b - Sort numerically with
(a, b) => a > b - Move
.slice(0, 3)before the.sort() - Replace
.filterwith.flatMaphere
The default sort compares as strings, so the top three are wrong for numbers.
Play Problem Solving ▸