Help needed to solve problem

Tell us what’s happening:

I can’t get the right answer, even after watching the video and hints several times. Please help!

Your code so far

function nextInLine(arr, item) {
// Your code here
var removed =arr.push();
return removed  // 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));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Stand in Line

Link to the challenge:

Welcome to forum, @haase1020!

The issue is that you didn’t remove an element from the beginning of the given array.
To remove the first element from the array,use shift
Hope this helps! :smile:

you are supposed to add the given item to end of the arr and remove the first element from the arr and return it
you can use .push() method to push item to end of the array
and then use .shift() method to remove first element from the array

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

1 Like