The code below runs without an error, but its result is wrong. Which statement correctly identifies the bug?
const scores = [9, 85, 100, 42];
scores.sort();
console.log("Highest:", scores[scores.length - 1]);
As strings the order is "100" < "42" < "85" < "9". With a numeric comparator the last element is 100 (or simply use Math.max(...scores)).