let arr = [1, 2, 3, 4, 5]
let steps = 2
let hold = arr
let indlength = arr.length - 1
for (let i = indlength; i > indlength - steps; i--) {
hold.unshift(arr[i])
hold.pop()
}
console.log(hold)
So I am attempting to rotate this array in javascript to the right by 2 rotations. Instead of getting 4,5,1,2,3 I am getting 3,5,1,2,3. I suspect it has something to do with an index being skipped, because if I up the steps to 3, it becomes 1,3,5,1,2. Here is a repl link https://repl.it/@helixlamont/ExoticTealOpengl