[Homework] JavaScript Basics - JavaScript Loops, Arrays, Strings - Problem {8} - Sort Array
var arr1=[5, 4, 3, 2, 1];
var arr2=[12, 12, 50, 2, 6, 22, 51, 712, 6, 3, 3];
function sortArray(arr){
var endOf=0;
var tempElm;
var elmIndex;
do{
tempElm=arr[endOf];
for(i=endOf;i<arr.length;i++){
if(tempElm>arr[i]){
tempElm=arr[i];
elmIndex=i;
}else {
continue
}
}
arr.splice(elmIndex,1);
arr.unshift(tempElm);
endOf=endOf+1;
}while(endOf != arr.length-1);
console.log(arr)
}
sortArray(arr2);
задача
Problem 8.Sort Array
нещо забих !!!!!