"Stand in Line" code works but is not registered as correct

"Stand in Line" code works but is not registered as correct
0

#1

Here’s my code:

  function nextInLine(arr, item) {
      // Your code here
      	arr.push(item);
      	var removed = arr.splice(0, 1);
    	return removed;
    }
    // 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));

I was able to submit it by using shift() instead of splice, but I’m still confused. Does anyone know what’s going on here? How come FCC wasn’t registering my code as correct?


#2

##Return value
An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.

Splice documentation

Splice returns an array.