How to do the Stand In Line challenge?

Okay, this is a perfect example of FCC being HORRIBLE at explaining what to do and how to do it lol. This challenge is impossible, I have no idea where to even start. Im pretty sure the reason I cant figure it out is because NOTHING IS EXPLAINED as far as how to do it!

Thereā€™s no instructions at all. Their ā€œinstructionsā€ are just guidelines of what theyā€™d like the outcome to be. Rather than an explanation on how to do it. In addition, the instructions assume that total beginners already know what their doing but Iā€™ll tell ya, Iā€™m looking at this code and I have no idea where to even start. My apologies for sounding ā€œrudeā€ but its frustrating.

Okay understandable and thank you for the explanation, although I think it would be wise for FCC to display that info somewhere then. Because Iā€™m not the only user whose had this problem with FCC. I think the main issue here is thereā€™s only 1 instance of each challenge. For example in 1 challenge, you do 1 and learn 1 thing, and then the next challenege you do 1 and learn 1 other thing. The lessons do not build onto one another, and only being able to practice 1 lesson with 1 problem, thatā€™s not going to help a beginner understand whatā€™s actually going on. Nor does it help develop the necessary mindset that one needs in order to perform these kind of tasks.

Okay, no that makes total sense actually. I appreciate you taking the time to help me out here with this challenge. I just did some research on how to complete each step and Iā€™ve got a better understanding now. Also, Iā€™ts free education so I guess I canā€™t be too picky about these things. Thanks again.

1 Like

Iā€™ll be honest, Iā€™m still really stuck. Even after looking over the previous lessons for the push() method and everything, I still canā€™t figure out what to start writing.

Below is my first step

nextInLine([2], 1) should return 2

Itā€™s telling me what it ā€œshouldā€ be, but how am I supposed to know what to actually start writing? Like how do you take a problem and automatically ā€œknowā€ what to start writing to solve the problem?

Below is my first step

nextInLine([2], 1) should return 2

Itā€™s telling me what it ā€œshouldā€ be, but how am I supposed to know what to actually start writing? Like how do you take a problem and automatically ā€œknowā€ what to start writing to solve the problem? Like do I start with a function or a variable or a loop or an if/else or how do you know what to start writing?

For example, the first step (above) says nextInLine([2], 1) but I donā€™t even see where it says that or is displayed like that in the actual problem at all. This makes no sense literally at all.

Did you read:

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

I would want to know the starting input and the finishing output before writing the code.

Yes I read it, but that still doesnā€™t make any sense whatsoever. Your saying ā€œI would want to know the starting input and the finishing output before writing the code.ā€ But whatā€™s that supposed to mean exactly? Like how would you know how to start writing that in code?

From previous examples you should have been introduced to .pop, .push, .shift, .unshift.

You can do this challenge with these functions.

https://www.freecodecamp.org/challenges/manipulate-arrays-with-shift
https://www.freecodecamp.org/challenges/manipulate-arrays-with-unshift
https://www.freecodecamp.org/challenges/manipulate-arrays-with-push
https://www.freecodecamp.org/challenges/manipulate-arrays-with-pop

Yes and I understand them all and what they do as well. But that doesnā€™t help when it comes to knowing how to start solving a problem, or how to start writing the code to solve the problem. Like do you start with a function or a loop or an if/else or what? Thats why Im confused, like how do you know what to actually start typing?

Test out the functions I mentioned and see what happens. That is what I did.

Okay but on line 6 it says ā€œreturn itemā€ and then // change this code.

Plus its got a bunch of JSON.stringify stuff attached to it thats confusing the hell out of me as well, do I need to do anything with that stuff?

JSON stringify changes an object to a string for outputting to the screen or console.

Also, in the directions, this is my first thing I have to do (nextInLine([2], 1) should return 2). But none of that is in the problem at all so how am I supposed to know what to start with? Man, Im so fucking confused you have no idea.

nextInLine says nextInLine(arr, item) so im not sure where their getting the array from or the 2 and the 1.

So in the instructions:
The nextInLine function should then return the element that was removed.

From the documentation for pop()
The pop() method removes the last element from an array and returns that element. This method changes the length of the array.

From the documentation for shift()
The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array.

PS.
The way FCC works is you are encouraged to read, search then ask.
This is because in a real job, you are expected to (eventually) do just that.

See man, your telling me this stuff but I already know all of this. But I dont think your understanding my problem. Okay so the actual 1st step is below:

nextInLine([2], 1) should return 2

Hereā€™s my problem, that exact line is nowhere in the actual code at all, so where the hell are they getting the 2 and the 1 from?

They are the passed in parameters to the function
[2] is an array (but it only has 1 element)
1 is the item

But arent the parameters (arr, item) though? Thatā€™s what it shows in front of me and not 2 and 1.

These are the defined ā€œargumentsā€ which are used by the function definition.

When the function is called with ā€œparametersā€ they are supplied to the function.

Parameter - MDN Web Docs Glossary: Definitions of Web-related terms | MDN ā† see definition