Tell us what’s happening:
Hi campers, I’m stuck at this stage of the challenge. What I don’t understand is how to return the removed item. I have tried
return arr.shift();
but that just removes another element from the array. I have also tried the explanations in similar questions on this forum but I’m just confused as to why people are adding “item” to the push and shift functions.
Your code so far
function nextInLine(arr, item) {
// Your code here
arr.push(6);
arr.shift();
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/65.0.3325.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/stand-in-line