Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
defintiely not pure if it performs a mutation to the parameter, pure functions don't have side effects
.toSorted could be used in modern js
Correct me if I am wrong but the sort method sorts the original array in place. The other methods do not mutate our array. So if we were to run the function multiple times on the same array, it will return the same result. We could then say that the function is pure. However, the original array has been mutated in ascending order. If other function manipulate that set of numbers relying on indexing, it could have side effects. So maybe not best practice. Here, creating a copy of the array before sorting could have avoided that issue.
Nice!