Problem with Stand In Line test?

Hey everybody! So I’m in the Stand in Line test in JavaScript basics, but the code that I have, which is identical to the solution, is not passing the 3rd and 4th test. Is anyone else having this problem? I was thinking it could be an issue with the test itself, but not sure:

  **Your code so far**

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

return takeOff;
// 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 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

Challenge: Stand in Line

Link to the challenge:

Hi @druskiii !

Welcome to the forum!

The problem is that you are not using one of the function parameters.

You shouldn’t write a function that only works for testArr.
This is wrong.

You need to write a function for arr.

Your function should work for a variety of arrays not just the testArr.

Hope that makes sense.

1 Like

Ahhh, that totally makes sense! I need to use the parameter, and not the actual example… because that’s considered hardcoding it? Either way, thank you!

1 Like

That’s right :grinning:

1 Like

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