• Courses
  • Code Compiler
  • Discuss
  • Pricing
  • Teams
Menu
+ 4

How to rotate an array?

For example, i have this a = [0,1,2,3,4] and rotate to: a = [1,2,3,4,0] in javascript

javascriptcode
22nd Sep 2018, 9:59 PM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
2 Answers
+ 1
https://code.sololearn.com/WYt6o5Ovei86/?ref=app
22nd Sep 2018, 10:32 PM
Arjun gowda
Arjun gowda - avatar
+ 3
function rotate(arr) { arr.push(arr.shift()); return arr; } https://code.sololearn.com/Wu96Lo7trkLY/?ref=app
22nd Sep 2018, 11:57 PM
Calviղ
Calviղ - avatar

Often have questions like this?

Learn more efficiently, for free:

  • Introduction to Python

    7.1M learners

  • Introduction to Java

    4.7M learners

  • Introduction to C

    1.5M learners

  • Introduction to HTML

    7.5M learners

See all courses
Hot today
Supervised learning, regression
2 Votes
I've Been Trying For an Hour
0 Votes
Programming languages that Sololearn offers
1 Votes
Comparing Numbers
0 Votes
Counting specific letter in string
1 Votes
𝗪𝗵𝗮𝘁 𝗱𝗼 𝘆𝗼𝘂 𝘁𝗵𝗶𝗻𝗸 𝗶𝘀 𝘁𝗵𝗲 𝗯𝗲𝘀𝘁 𝗮𝗻𝗱 𝗺𝗼𝘀𝘁 𝘃𝗮𝗹𝘂𝗮𝗯𝗹𝗲 𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗹𝗮𝗻𝗴𝘂𝗮𝗴𝗲?
1 Votes
Can someone explain Inheritance in html and css?
1 Votes
HOW TO CREATE A LINK WITHIN SOLO LEARN
1 Votes
is it worth it ?
0 Votes
Publishing
1 Votes