I want to use the same variable array
to output the reverse an integer array. But, I only got the first value print out. Not sure where I did wrong.
Here is my code:
let array = [3, 8, 9, 6, 4, 2]
reverseArray(array);
function reverseArray(array){
let left =0;
for(i = 0; i <= array.length - 1; i++){
let right = array.length - 1 - i;
let temp = right;
right = left;
left = temp;
array = array[left];
}
console.log(array);
}