Link to the reverse method.
AFFILIATE LINKS
Great resource I use to learn algorithms.
40% off Tech Interview Pro: http://techinterviewpro.com/terriblewhiteboard
20% off CoderPro: http://coderpro.com/terriblewhiteboard
Here is the full implementation.
let rotate = function(nums, k) {
k = k % nums.length;
while (k > 0) {
nums.unshift(nums.pop());
k--;
}
};