Basic JavaScript - Stand in Line

Good Morning folks. I am having some issues understanding a few points from the stand in line challenge. How come there is an testArr const variable that is able inputed in the nextInLine func with the arguments arr that is spelled differently and item i do not understand at what point that was defined in the func. It just seems like magic that the soultion worked.

   **Your code so far**
function nextInLine(arr, item) {
 // Only change code below this line
 return arr.shift();
 // 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Stand in Line

Link to the challenge:

The function arguments show what is passed into the function.

1 Like

I’m sorry, I find myself in the same position than OmegaFruitPunch, and I don’t get your comment’s relevance. I don’t understand the link between testArr and the function.

We could certainly provide more help for you but please open your own topic by clicking on the Ask for Help button in the challenge.

In the meantime, you can think about how functions are supposed to work (or review some older exercise on what they are)

Hi there,

I hope that @OmegaFruitPunch doesn’t mind if I’ll add to his question - my own - as a newbie in JavaScript I struggle with some of the explanations found in the Curriculum, so when I managed to figure out a solution for this challenge I was more then happy…then I start lurking at the forum and my answer is different from @OmegaFruitPunch.

If some more experience forum members are so kind and to let me know if my would be still valuable in real-world application - I would appreciate it a lot.

here’s my solution:


// sorry for a long post

1 Like

I thought it would be best to gather it all together seeing as we have the same question… I know that when I look for answers among already asked questions it’s annoying sifting through different posts.

yes I feel you.
But FCC has about a million users at the moment and imagine having all of them in one thread asking questions… Not fun.

1 Like

Hi, welcome to the forum.

If you don’t mind asking your question in a separate topic please, then someone can help you. (click on the Ask for Help button in the challenge and it should allow you to place your questions and code there)


Hi @hbar1st ,

thanks for the reply - I’ll pass with posting another question - will check more topics on the forum first, then re-do some of the exercises - I should understand more :slight_smile:

1 Like

Gotcha. Thanks for your work!

1 Like

Thanks. I’m a volunteer here (as many are). If you’re interested one day:

1 Like