Stand In Line javaScript Exercise ! Stuck!

Stand In Line javaScript Exercise ! Stuck!


I just solved this thanks to you Chad - thanks!


Much appreciated, thanks for the help. After realizing it took me 2 hours to figure out a 2-line challenge, kinda embarrassing. But its the learning process!


i still dont know how it worked but it passed with below code…

function nextInLine(arr, item) {


return arr.shift(); // Change this line


// 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));


So perfect and clear explanation :slight_smile:


Function nextInLine(arr, item) {
return arr.push(item) && are.shift();
That should solve the problem


We would rather you didn’t post full working solutions, instead try to help other campers understand how to solve it themselves. Your solution is different enough from the standard basic solution to make me think it’s reasonable to post it, but you need to explain why it works: it’s too complex and tricky a solution to just dump it there on its own without explanation (it requires knowledge of how to short-circuit boolean operators to understand what it’s doing)