Menu
Coddy logo textTech

17. Rotate Array

Lesson 18 of 31 in Coddy's 30 Days of Logic Building in Javascript course.

challenge icon

Challenge

Medium

Write a function to rotate elements in an array to the right by a given number of steps.

  • Input: <strong>[1, 2, 3, 4, 5]</strong>, <strong>2</strong>
  • Output: <strong>[4, 5, 1, 2, 3]</strong>

Try it yourself

function rotateArray(steps, arr) {
    // write your code below
    
}

All lessons in 30 Days of Logic Building in Javascript