Can i please explanin what is this fuction nextLine (arr,item)

Tell us what’s happening:

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 (Linux; Android 9; SM-A105F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Mobile Safari/537.36.

Challenge: Stand in Line

Link to the challenge:

Hello there.

Could you be more specific as to what is confusing you?

For future posts, it helps to fill in the Tell us what’s happening section

1 Like

Im confuse because (arr,item) why we use this to arrgumeent and then the name is var arraylist why

there is nothing with name of arraylist

if you don’t understand what the function is, can I suggest reviewing previous lessons?

@Ahmed15

So you want to know what those two values mean (arr,item).
You basically have an array of converted strings, with a number called item in this case let said 6 or can be other number.
So now you have an (array[1,2,3,4,5] , item(6) )
you want to pass this two values into a function called nextInLine() will receive two values. This values are (array[1,2,3,4,5] , item(6) ), into this function(arr, item) respectively. (have same two values.)
Example:

// NextInLine function
function nextInLine(arr, item){ // its the same as passing values (array[1,2,3,4,5] , item(6) ).
};   
1 Like