JSFiddle - React, Tailwind, and code Playground

by Sudheer Nunna

JavaScript

function shiftArray(array,index,arraylength){
 
 const temp = new Array(arraylength);
 let tempcount=0;
 for(let a=index;a<arraylength;a++){
 temp[tempcount] = array[a];
 tempcount++;
 }
 
 for(let b=0;b<index;b++){
 temp[tempcount] = array[b];
 tempcount++;
 }
 
console.log(temp);

}

const arrayData= [2,3,4,6,5,2];
shiftArray(arrayData,2,arrayData.length);