Tell us what’s happening:
I think that I got the swapping, but I do not know how to set them in the array again
Your code so far
function selectionSort(array) {
let minNumber=0;
let temp=[]
for(let i=0;i<array.length;i++){
minNumber=Math.min(...array)//I find the min Number in the array
if(minNumber!=array[i]){//If they are different
temp[0]=array[i]//I set the index in temp
temp[1]=minNumber//I set the min number in the index
}
array=array.slice(i)// I make the same in every cycle
}
}
selectionSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36
.
Challenge: Implement Selection Sort
Link to the challenge: