let array=[3,5,2,6,1,7,4]; // output "1,7,2,6,3,5,4"
let pivot = 4;
console.log(array);
let ascending=[];
let descending=[];
let new_array=[];
for(let i=0;i<array.length;i++){
if(array[i]<pivot){
descending.push(array[i]);
}
else if(array[i]>pivot){
ascending.push(array[i]);
}
}
descending.reverse();
ascending.reverse();
console.log(descending); // reversed descending value 1,2,3
console.log(ascending); // reversed ascending value 7,6,5
Hello i want to shift the values from original array that is [3, 5, 2, 6, 1, 7, 4] to use the ascending array while looping if the array[i] is bigger than 4 to use 7,6,5 and when its smaller than 4 to use descending array of 1,2,3 so the outcome will be 1,7,2,6,3,5,4