loading...

re: Not an "Easy" Algorithm: Rotating an Array, Three Ways VIEW POST

FULL DISCUSSION
 

I would have though the shortest version of (1) would be:

    let rotate = (arr,n) => (arr.unshift(...arr.splice(-n % arr.length, n % arr.length)), arr)

Though I guess the splice allocates an array of size n % length

code of conduct - report abuse