Stand in Line - Help please

Tell us what’s happening:
I don’t know how to solve that challenge. I’m really stucked here. Help, please.

Your code so far


function nextInLine(arr, item) {
  // Your code here
  
  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:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line

Your code needs to do two things:

  1. Add a number to the end of an array.
  2. Remove an item from the beginning of the array, then return it.

You should know how to do all of these things from previous lessons:

Manipulate arrays with push
Manipulate arrays with shift

How do you combine this knowledge to write the function you need?

I don’t know, that’s the problem. That’s what i’m typing:

function nextInLine(arr, item) {
// Your code here
testArr.push(6);
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));

But the console is giving me some errors:

// running test
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
// tests completed

I’m also stuck on this. any luck???