Can't understand what's going on

Tell us what’s happening:
I can’t understand what to do in the lesson.
I copied the answer from the hint in hopes that I may be able to understand but eventually failed.
Also , Can .push() and shift() be applied on variables as well as arguments?
plz help!

For more info plz click the link below.
Thank You.

Your code so far


function nextInLine(arr, item) {
// Only change code below this line
arr.push(item);
return arr.shift();
// Only change code above this line
}

// Setup
var 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/85.0.4183.121 Safari/537.36.

Challenge: Stand in Line

Link to the challenge:

Can you be more specific about what confuses you?

Arguments are variables. push and shift are methods that can be called on any array.

1 Like

Thank you for replying
At first I didn’t understand what to write in answer. So I decided to check the answer in the hint . But I didn’t understood that too .
So in short I would like to understand why the answer is so.

first, do you understand what the challenge asks for?

Well, yeah .

  1. add number 2) shift the first element

Thanks a lot for helping me.

I think it would be good if you just explain to me the answer . I don’t want to trouble you.

Do you know what push does? Do you know what shift does? Did you look these up and get confused by the explanation? What part don’t you understand?

After these msg I understood that I didn’t actually understand the applications of the properties properly and was doing wrong so I searched on the net and understood the properties and also cleared the lesson .
Thank you for the help.

1 Like

Congratulations on figuring it out! Trying to find what to research and how to research it is one of the challenges that continues through your coding life.