Last active
February 14, 2023 12:38
-
-
Save dcortesnet/d66067e8d4320a053ef7cc4d95f609f5 to your computer and use it in GitHub Desktop.
Javascript resolución de pr rotación a la izquierda array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rotateLeft(d, arr) { | |
| while (d > 0) { | |
| const leftElement = arr.shift(); | |
| arr.push(leftElement); | |
| d--; | |
| } | |
| return arr; | |
| } | |
| console.log(rotateLeft(2, [1, 2, 3, 4, 5])); // [3, 4, 5, 1, 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment