A leaderboard needs numeric order, but the incoming scores should stay untouched. Both sort() and reverse() mutate the array on which you call them. Copy first when you need to keep an earlier order.
const raceTimes = [8, 42, 15];
const alphabetical = raceTimes.slice().sort();
const leaderboard = raceTimes.slice().sort((a, b) => a - b);
console.log(JSON.stringify(alphabetical));
console.log(JSON.stringify(leaderboard));
console.log(JSON.stringify(leaderboard.slice().reverse()));
console.log(JSON.stringify(raceTimes));
Without a comparator, sort() compares string spellings, so 15 comes before 8. The numeric comparator (a, b) => a - b returns a negative number when a should come first, zero when they tie, and a positive number when b should come first.
Run the block and compare the two sorts. reverse() flips the current order; it does not decide which numbers are greater. Reversing a numerically sorted copy produces descending order.
slice() is the copy operation you already know. You may also see [...numbers]: inside an array literal, spread inserts each source item into a new array. This differs from the destructuring rest pattern, which collects values into a variable.
sortedNumbers to a copy of numbers sorted numerically with (a, b) => a - b. Keep numbers unchanged.reversedNumbers to a reversed copy of sortedNumbers; leave sortedNumbers in ascending order.Edit script.js, then Run after each step. The supplied probes show the values being checked; leave them in place. Submit checks the numbered tasks in order. You do not need to write extra checkpoint logs.
Use a copy like [...numbers] before sorting so you do not lose the original array.
Call reverse() after sorting if you want descending order.