Stand in Line - Fails Test with answer given in guide

Tell us what’s happening:
The answer is correct, I copied it from the Guide, and yet the tests fail…

// running tests
nextInLine([], 5) should return a number.
nextInLine([], 1) should return 1
After nextInLine(testArr, 10), testArr[4] should be 10
// tests completed

Your code so far

function nextInLine(arr, item) {
  // Your code here
  arr.push[item];
  return arr.shift();  // 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 (X11; CrOS x86_64 12105.31.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.24 Safari/537.36.

Link to the challenge:
javascript-algorithms-and-data-structures/basic-javascript/stand-in-line

You have a syntax error in this line:

  arr.push[item];

Look at it carefully. Look at the syntax for push, and see if you can spot the error.

Give up

You are using square brackets ([]) instead of parenthes (()).

1 Like

Well hot damn I am! I looked at that for like 20 minutes… Should have walked away from the screen for awhile :wink:

Thank you!

I’m glad I could help. Happy coding!