Algorithms 101: Rotate Array in JavaScript - three solutions

added by JavaScript Kicks
11/18/2019 11:50:39 AM

428 Views

Noob v. Algorithms #22, playing with .pop(), .unshift() and .splice() Browsing through the top interview questions in LeetCode, one of the harder easy questions is this one: The easiest solution is to use JavaScript's .pop(), which destructively removes and returns the last element of the array ( MDN documentation here), in combination with .unshift(), which destructively adds elements to the start of the array ( MDN documentation here).


0 comments