constinsertionSort=(array)=>{constarr=Array.from(array);// avoid side effectsfor(leti=1;i<arr.length;i++){for(letj=i;j>0&&arr[j]<arr[j-1];j--){[arr[j],arr[j-1]]=[arr[j-1],arr[j]];}}returnarr;};
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Insertion Sorting for Beginners in JS
For further actions, you may consider blocking this person and/or reporting abuse