Rotate An Array

Rotate an array to the left or right. So, [1, 2, 3, 4, 5] rotated right twice would be [4, 5, 1, 2, 3] Hint: there is a formula for calculating array rotation, so if you're stuck you can just use that :3 (I won't say what it is here just in case you'd rather not use it) - rainy.boyo (Discord)

examples

rotate([1, 2, 3, 4, 5], 2) // [4, 5, 1, 2, 3]
rotate([1, 2, 3, 4, 5], -2) // [3, 4, 5, 1, 2]