Error in implementing selection sort in JavaScript
This code is to implement selection sort in JavaScript. I tried with the array [3,2,1] but it return [1,1,1]; the array [4,5,1,2,7] return [1,1,1,2,7]. I don't know where I went wrong. Please help! function selectionSort(a) { var temp; for (let…