I understand that i have to use .push and .shift functions and what they are for.
But still i cant pass this level.
I’m only missing two checkmarks ![]()
“nextInLine([2], 1) should return 2”
“'Failed:nextInLine([5,6,7,8,9], 1) should return 5”
I don’t know why they won’t pass
Your code so far
function nextInLine(arr, item) {
// Only change code below this line
testArr.push(item)
const removed = testArr.shift(arr)
return removed;
// 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));
Challenge: Basic JavaScript - Stand in Line
Link to the challenge: