cf.completefrontend

Predict the outputEasy

What does sort() with no comparator do to an array of numbers?

What does this log?
const nums = [10, 1, 5, 100, 25];
const sorted = nums.sort();
console.log(sorted);
console.log(sorted === nums);
console.log(nums.sort((a, b) => a - b));
console.log(["b", "a", "C", "B"].sort());

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…