Stand in Line: Returning 1, 10

Tell us what’s happening:
I keep returning 1, 10 instead of just 10 how do i fix that?

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, 10), testArr[4]); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
1 Like

i dont know what your trying to do here as i dont know what lesson this is but shift() returns the removed item that’s why your getting 1

You get 1, 10 in the console because this is printing the value returned by the function (nextInLine(testArr, 10) plus the last item in the array (testArr[4]) after the function running, it is actually correct what you are seeing