function nextInLine(arr, item) {
// Only change code below this line
function nextInLine(arr,item){
arr.push(item)
return arr.shift()
}
return item;
// Only change code above this line
}
// Setup
let testArr = [1, 2, 3, 4, 5];
// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));
I’m not passing the last test which is the following;
nextInLine([2], 1)
According to freecodecamp, this should return 2. However I don’t understand why because the function nextInLine is supposed to basically push number 1 to the array and remove 2 which is the first value of the array.