Tell us what’s happening:
i don’t understand the logic behind this i have looked at it for too long already
Your code so far
function nextInLine(arr, item) {
// Your code here
arr = [];
arr.push(item);
var removed = arr.shift()
return removed; // Change this line
}
// Test Setup
var testArr = [5,6,7,8,9];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log(nextInLine([],5));
console.log(nextInLine([],1));
console.log(nextInLine([2],1));
console.log(nextInLine(testArr,5));
console.log(nextInLine(testArr[4]));
console.log("After: " + JSON.stringify(testArr));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line/