A queue is an abstract Data Structure where items are kept in order.
New items are added to the back of the queue, and old items are taken off.
Final Code
functionnextInLine(arr,item){// Only change code below this linearr.push(item);arr.push(item);returnarr.shift();// Only change code above this line}// SetupvartestArr=[1,2,3,4,5];// Display codeconsole.log("Before: "+JSON.stringify(testArr));console.log(nextInLine(testArr,6));console.log("After: "+JSON.stringify(testArr));