Skip to content
Subhajit Sahu edited this page Mar 15, 2020 · 23 revisions

Rotates values in array.

array.rotate(x, n);
// x: an array
// n: rotate amount (-ve: left, +ve: right)
const array = require('extra-array');

var a = [1, 2, 3, 4];
array.rotate(a, 1);
// [4, 1, 2, 3]

array.rotate(a, 2);
// [3, 4, 1, 2]

array.rotate(a, -1);
// [2, 3, 4, 1]

references

Clone this wiki locally