fork download
  1. function test3(arr, r) {
  2. for (let i = 0; i < r; i++) {
  3. arr.unshift(arr.pop());
  4. }
  5.  
  6. return arr;
  7. }
  8.  
  9. const arr = [1,2,3,4,5,6];
  10. const R = 3;
  11. console.log(test3(arr, R));
Success #stdin #stdout 0.03s 16820KB
stdin
Standard input is empty
stdout
4,5,6,1,2,3