```
/**
* @param {number[]} nums
* @param {number} k
* @return {void} Do not return anything, modify nums in-place instead.
*/
var rotate = function(nums, k) {
let n = nums.length;
if (n === 0) return;
k %= n;
if (k === 0) return;
nums.unshift(...nums.splice(n - k, k));
};
```