array-test-tomasbarcojo
v2.1.5
Published
A funtion to rotate an array
Downloads
27
Readme
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-tomasbarcojoUsage
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 ]