You must log in or register to comment.
Honestly this being javascript I expected the answer to be
[4, 1, 100000, 30, 21]
(sorted alphabetically by name)
This is due to the default sorter in JavaScript sorting by the string value. The reason for that is that this won’t create errors at runtime. Since JavaScript does not have types, this is the safest way of sorting.
This works:
const unsorted = [1, 100000, 21, 30, 4] const sorted = unsorted.sort((a, b) => a - b)
Looks like they should have called that function
sortOf()
JavaScript was made in 2 days through a drunken stupor, and it shows.