+ 4

How to rotate an array?

For example, i have this a = [0,1,2,3,4] and rotate to: a = [1,2,3,4,0] in javascript

22nd Sep 2018, 9:59 PM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
2 Answers
22nd Sep 2018, 10:32 PM
Arjun gowda
Arjun gowda - avatar
+ 3
function rotate(arr) { arr.push(arr.shift()); return arr; } https://code.sololearn.com/Wu96Lo7trkLY/?ref=app
22nd Sep 2018, 11:57 PM
CalviŐČ
CalviŐČ - avatar