Stand in Line - How to create a Que using the shift pop push and unshift functions

Stand in Line - How to create a Que using the shift pop push and unshift functions
0

#1

Tell us what’s happening:

Your code so far

function nextInLine(arr, item) {
  // Your code here
arr.shift();
arr.push(item);
  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36.

Link to the challenge:


#2

You are very close, but need to read the instructions again carefully.

  1. What value are you asked to return?
  2. What order should your current code be executed in once you are returning the correct value?

#3

Thanks, solved by adding variable with value of arr.shift()