Stand in Line let removed = arr.shift([0]);

Tell us what’s happening:

Hi guys!

Hope you’re doing well.

If someone know, can you please explain why my code is not going through? It seems that on repl.it it works.

Your code so far


function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  let removed = arr.shift([0]);
  return removed;  // 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_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

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

your function takes an argument arr, which you use in let removed = arr.shift([0]);, and that’s ok

but consider what your line testArr.push(item); does. What happens if you call for example nextInLine([], 1);?

ah, arr!!! =)

I needed to use arr =) thank you!