What is the error in this case? Even with the solution provided is not possible to solve it

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
function nextInLine(arr, item) {
// Only change code below this line
arr.push(item);
const removed = arr.shift();
return arr.shift();
// Only change code above this line
nextInLine ([], 5);
nextInLine ([], 1);
nextInLine ([2], 1];

}

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

// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.160 YaBrowser/22.5.1.985 Yowser/2.5 Safari/537.36

Challenge: Stand in Line

Link to the challenge:

you are removing two elements, not one

also, you don’t want to have function calls inside the function itself

why are these inside the function?

Thanks for the hint in the first part. Should I then specify the item I want to manipulate? Will try to implement that asap. Now, for the second part of the answer, it seems that it is given by default and cannot be changed, so no idea why those commands are there in the first place.

you are, but you are removing two different items, when you should remove one

no, the starting code does not have those, as it is so:

function nextInLine(arr, item) {
  // Only change code below this line
  
  return item;
  // Only change code above this line
}

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

// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));
1 Like