Stand in line(not understand)

Tell us what’s happening:

I can get the result 2,3,4,5,6 with the following code, but I don’t seem to have the right answer?

  **Your code so far**

function nextInLine(arr, item) {
// Only change code below this line
var x = arr.shift();
return x;
// Only change code above this line


// Setup
var 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 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

Challenge: Stand in Line

Link to the challenge:

what happens if you call nextInLine(testArr, 10)? a 6 is added at the end of testArr, instead of 10


the problem is in your


You’re pushing a fixed value (6) instead of pushing item argument that you’re required to push

1 Like

but why when i push an item to the array, it becomes a value automatically?
did i miss something i supposed to know?

Hey mate :slight_smile:

The problem is that you push a fixed value, I mean:


You must push a value from here:

nextInLine(arr, **item**)```

In order to make your app push anything, just try:


Best of luck!

the value of item is determined by the function call

the value of item here is 6

the value of item here is 10

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.