My goal is not to use any Bubble/Section/Insertion/Merge/Quick Sort—nothing built in.
I am trying to figure out how to:
let arr = [2, 8, 7, 3]
for(let i = 0; i < arr.length; i++) {
//here I want to number use numbers as an index let's say: arr[0] is 2 right?
// I want to set number 2 at index 2 - 1
//arr[1] = at index 8 - 1
//arr[2] = at index 7 - 1
//arr[3] = at index 3 - 1
//output will be : arr [2, 3, 7, 8]
//here index of each num ^ ^ ^ ^
// 1 2 6 7
}
here I tried to remove empty items but I lost whole numbers.screenshot
let arr =[1,3,4,5,6]
let copyArr = [...arr]
copyArr[199] = 200
copyArr[149] = 150
console.log(copyArr)
let str = copyArr.toString().replaceAll(',','').split('')
console.log(str,)
// OUTPUT BELOW:
//copyArr:
// [ 1, 3, 4, 5, 6, <144 empty items>, 150, <49 empty items>, 200 ]
//str :
// [
// '1', '3', '4', '5',
// '6', '1', '5', '0',
// '2', '0', '0'
// ]