function insertionSort(arr){
for(i=0;i<arr.length;i++){
for(j=i+1;j<arr.length;j++){
console.log(i);
console.log('j='+j);
if(arr[i]>arr[j]){
console.log('true'+arr[i]);
var temp=0;
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
console.log(arr);
}
}
}
return arr;
}
console.log(insertionSort([0,2,34,22,10,19,17]));
function selectionSort(arr){
const swap = (arr,idx1,indx2) =>
([arr[idx1], arr[idx2]] = [arr[idx2], arr[idx1]]);
for (let i = 0 ; i< arr.length; i++){
let lowest = i;
for (let j = i+1; j< arr.length; j++){
if(arr[lowest] > arr[j]){
lowest = j;
}
}
if(i !== lowest) swap(arr,i,lowest);
}
return arr;
}
console.log(selectionSort([0,2,34,22,10,19,17]));