Basic JavaScript - Stand in Line

I understand that i have to use .push and .shift functions and what they are for.
But still i cant pass this level.
I’m only missing two checkmarks :slight_smile:

nextInLine([2], 1) should return 2

“'Failed:nextInLine([5,6,7,8,9], 1) should return 5

I don’t know why they won’t pass

Your code so far

function nextInLine(arr, item) {
  // Only change code below this line
  testArr.push(item)
  const removed = testArr.shift(arr)

  return removed;
  // Only change code above this line
}

// Setup
let 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));

Challenge: Basic JavaScript - Stand in Line

Link to the challenge:

Hi there and welcome to our community!

The issue is that you should be working with the function parameters, rather than explicitly modifying testArr (i.e. you should be pushing/shifting arr).

Also, if you want to remove the first item from an array, you simply tack on the shift method to the array and don’t include any values within the parentheses.