Stand in Line issues, and not fully understanding why I shouldve known to use Push/ shift

Tell us what’s happening:
Describe your issue in detail here.

I’ve been learning to code via this website and a few others. And I want to be very clear about this, this lesson was by far the most confusing I’ve came across. I watched this video after trying several different things and what’s being asked to be done here is not conveyed eloquently enough for it to “click” that I should be using Push and Shift here. It assumes that the user or student is just going to remember to do this without a reminder. It would help significantly if there was a section added to these lessons that said, “for a quick recap of what you need to do here, go to this lesson or this lesson”. It honestly infuriated me when I watched this answer video.

  **Your code so far**

function nextInLine(arr, item) {
// Only change code below this line

return 0;
// Only change code above this line

// Setup
const 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));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

Challenge: Stand in Line

Link to the challenge:

After teaching students about the types, data structures, and methods that are commonly used in JavaScript, the curriculum becomes focused on developing skills via increasingly complex tasks. One of the key skills in problem solving with code is figuring out which method or structure to use. That will usually not be included in the challenge description.

What you might find useful is the links at the top.

If you click on Basic JavaScript it will take you to the list of challenges in the course, so you can scroll through to find previous lessons that might be helpful. For instance, since you are dealing with an array in this case, you might look back at the lessons and decide to review the “Manipulate an Array with…” lessons:

Going back and referencing previous work to figure out how to solve a new problem is something we do all the time as programmers.

1 Like

There is also the Hint page (Get help > Get a hint).

The solutions are hidden so it won’t spoil anything and the page usually has some extra information.

I guessed the push and shift part. The issue is how vague the instructions are and the naming of variables/arrays in the setup.

“Create a function that adds a 6 to the queue and removes/returns the first item. Note the ‘JSON.Stringify’ lines - this is a JS feature we will cover in depth in the future.” - Same exercise, less confusion.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.