selectionSort
Sorts an array of numbers, using the selection sort algorithm.
- Use the spread operator (
...
) to clone the original array,arr
. - Use a
for
loop to iterate over elements in the array. - Use
Array.prototype.slice()
andArray.prototype.reduce()
to find the index of the minimum element in the subarray to the right of the current index and perform a swap, if necessary.