Stand in Line it says nextInLine is not defined

Tell us what’s happening:
i’ve re-edited this code multiple times and i’m stuck pls help me out

Your code so far


function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log(nextInLine([],1));
console.log(nextInLine([],5));
console.log(nextInLine([2],1));
console.log(nextInline(testArr,10));
console.log(nextInline(testArr[4]));
console.log("After: " + JSON.stringify(testArr));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.

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

It is saying that nextInline is not defined, check capitalization

Also, the second of these calls will tell you that arr.push is not a function, because you don’t have an array as first argument, but a number, and so it is not possible to use array methods on numbers

1 Like

It is not defined, because in these lines of code the name of the function is written incorrectly.

console.log(nextInline(testArr,10));
console.log(nextInline(testArr[4]));
1 Like

i just fixed that thanks, but now it says arr.push()is not a function can you help me fix that too

1 Like

thanks i just fixed it

no worries i just fixed it thanks