const arr = [1,3,5,7,9,2,4,6,8]; for(let i=0;i<arr.length;i++){ for(let j =0;j<arr.length;j++){ var n; if(arr[i]<arr[j]){ n = arr[j]; arr[j] = arr[i]; arr[i] = n } } } console.log(arr)