Idk what's wrong in Stand in Line

Your code so far

function nextInLine(arr, item) {
  // Your code here
  return testArr.shift() - 1;  // 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_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36.

Link to the challenge:

That’s a good question, what is wrong with it? What is your actual returned values compared to your expected?

one first issue is that you are using testArr inside the function and not the function parameter arr, if you use the function parameter that will make your code work with all the values passed in, you should always use function paramenters instead of global variables, remember this, and you will have an easy time passing challenged and creating code that works.

this will still not make it returns the right value, as in below:

nextInLine([1], 2); // returns 0, expected value 1
nextInLine([4,5,6,7], 8); // returns 3, expected value 4