+ 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
2 Answers
+ 3
function rotate(arr) {
arr.push(arr.shift());
return arr;
}
https://code.sololearn.com/Wu96Lo7trkLY/?ref=app
For example, i have this a = [0,1,2,3,4] and rotate to: a = [1,2,3,4,0] in javascript