Shifting all the values in an array one index higher with the displaced last element placed as the first element
<p>I'm struggling with the below code in JS please help:</p>

<p>Currently trying to get</p>

<p>[20,30,40,50]</p>

<p>to be</p>

<p>[50,20,30,40]</p>

<p>any tips?</p>

<p>Here is the code I have so far below!</p>

<pre><code>// A program to shift all the values in an array one index higher, with the displaced last element being placed as the first element

var test = [20,30,40,50];

for (i=0; i&lt;test.length;i++)
{
    alert(test[i] + " is currently index: " + [i]); 
    }

test[0] = test[test.length-1];

for (i=0; i&lt;test.length;i++)
{
    alert(test[i] + " is now index: " + [i+1]); 
    }
</code></pre>
