diff --git a/sorting/js/selection-sort.js b/sorting/js/selection-sort.js index 69f312b2..088c4d7e 100644 --- a/sorting/js/selection-sort.js +++ b/sorting/js/selection-sort.js @@ -1,15 +1,25 @@ -let sort = [12,6,3,88,1,4,8] +function selectionSort(array) { -for(let i=0; isort[i]){ - //swaping elements - let temp = sort[i]; - sort[i]=sort[j]; - sort[j]= temp; + // loop through all elements except last in array + for(let i=0;i