2.1.5 • Published 3 years ago
array-test-tomasbarcojo v2.1.5
Rotation of an array
A fuction to rotate 'k' times left or right an array.
Installation
Use the package manager npm to install.
npm i array-test-tomasbarcojo
Usage
Positive number: rotates to right Negative number: rotates to left
import { rotateArray } from 'array-test-tomasbarcojo'
let test = [1, 2, 3, 4, 5]
rotateArray(test, 2) # returns [ 4, 5, 1, 2, 3 ]
rotateArray(test, -2) # returns [ 3, 4, 5, 1, 2 ]