I have not asked any question yet in this type of forum and yes I have a question too that how this code is taking the sequence of counting cause i didnot put the 6 but it gives the correct answer.
I’ve just run the code you posted.
The test result is:
// running tests
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
// tests completed
Not passing. It is not corect solution for this step for a couple of reasons. That’s why I am a bit confused when you are saying that it is giving correct answer
Why are you pushing 6 to the array? What if the user inputs a different value for item?
You are not supposed to return item. You are asked to return the value of the number which is removed from the array, not the number which was added.
TOP TIP:arr.shift() not only removes the first item from an array but also returns the removed value. So you could combine your return statement with this method.