Rotate the elements of an array by an amount specified. Essentially increments the index of every element by the amount, and elements at the end wrap round to the start.
the rotated array
rotateArray([1, 2, 3]) === [3, 1, 2]
rotateArray(['a', 'b', 'c'], -1) === ['b', 'c', 'a']
rotateArray(['🍎', '🍐', '🍋'], 2) === ['🍐', '🍋', '🍎']
array to rotate
number of elements to rotate by (default: 1)
Generated using TypeDoc
Rotate the elements of an array by an amount specified. Essentially increments the index of every element by the amount, and elements at the end wrap round to the start.
Returns
the rotated array
Example
Example
Example