Task of Challenge #20
Rotate an array to the left 1 position. E.g. [1, 2, 3, 4, 5] -> [ 2, 3, 4, 5, 1 ] | [1, 2, 4, 5] -> [ 2, 4, 5, 1 ].
You can achieve the challenge’s goal quite easily by using the
shift() and the
push() method for arrays. The
shift() method removes the first element of an array and returns it. If we store it now into a variable (in this case first) then we can use the
push() method to push it as the last element of an
If you want to dig deeper into
To get a discount, just subscribe to my newsletter.
The output for the code above is:
Follow me on Instagram and don’t miss the latest Challenge!
Become a bullet proof developer and seek my coding adventures on Udemy
Don’t Miss My Most Read Article with over 8000 Views
Typescript saves a lot of development time, but is it worth an entire migrating process?
Upgrade Your Legacy Coding Style With These 6 Modern Ways of Coding