Array.sort - descending
Easy
9
76.0% Acceptance
In this coding challenge, you will be implementing a function called sortDescending(numbers)
, which takes in an array of numbers
as input and returns the same array but sorted in descending order.
Instructions
- If the input array is empty, return an empty array.
- Sort the array in place.
Example test cases
const numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]; sortDescending(numbers); console.log(sortedNumbers); // Output: [9, 6, 5, 5, 5, 4, 3, 3, 2, 1, 1]
Hints
- You should use the built-in
.sort()
method.