Stand in Line - help pls

Hi all,
I’m very new to the coding world. And I’m having trouble with the following task in javascript. Think I’ve got the first bit right. But obviously not all. Any help really appreciated. thanks.

“Write a function nextInLine which takes an array ( arr ) and a number ( item ) as arguments.
Add the number to the end of the array, then remove the first element of the array.
The nextInLine function should then return the element that was removed.”

I’m getting the following errors:

nextInLine([], 1) should return 1
After nextInLine(testArr, 10), testArr[4] should be 10
// tests completed ```

Any help or ideas welcome.


function nextInLine(arr, item) {
  // Your code here
  return arr.shift();

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

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

This line is semi confusing.

After nextInLine(testArr, 10), testArr[4] should be 10

If you look at the previous tests they are all returning the first element in the array.
This last test deviates from that pattern and does an additional check. Perhaps word it differently? ie.,
should return 4 and testArr[4] should be 10 when testArr is [4, 5, 6]

As for the OPs question:
You are pushing 6 every time. You should be pushing an argument provided by the function’s parameters.

Thanks kerafyrm02,
It’s passing now with:

function nextInLine(arr, item) {
  // Your code here
  return arr.shift();