Write a function named sorted
that will be used to extend the Array prototype.
This function should have the exact same signature as the existing sort
method, but it should return a new Array instead of modifying the original one.
Array.prototype.sorted = sorted;
const numbers = [1, 2, 3, 4, 5];
const descendingNumbers = numbers.sorted(
(nr1, nr2) => nr2 - nr1
);
console.log(numbers); // [1, 2, 3, 4, 5]
console.log(descendingNumbers); // [5, 4, 3, 2, 1]