Tell us what’s happening:
A little stuck here, can’t quite seem to figure out what I’m doing wrong here…
Passes everything but the following two:
nextInLine([2], 1)should return
2nextInLine([5,6,7,8,9], 1)
should return 5
Your code so far
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removed = arr.shift();
return item; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([2, 1]); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 12239.67.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.102 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line/