diff --git a/Rotate an array to the left 1 position.js b/Rotate an array to the left 1 position.js new file mode 100644 index 0000000..205d71b --- /dev/null +++ b/Rotate an array to the left 1 position.js @@ -0,0 +1,9 @@ +var ar = [1, 2, 3]; +rotateLeft(ar); +println(ar); + +function rotateLeft(ar) +{ + var first = ar.shift(); + ar.push(first); +}