Stand in Line - challenge what am I missing?

Hi there, I am reading all the responses to this and am still a bit stumped as to how to move past the 2-4 requirements:


I understand that you need to use push() and shift() and adjust the return but beyond that I’m still a bit confused as to what I need to do next.

Here’s the code I have so far:


Your browser information:

Link to the challenge:

Inside the function you should use the “arr” argument, not the “testArr” array.
When you call

console.log(nextInLine([5,6,7,8,9], 1));

your function use the “testArr” array not the “[5,6,7,8,9]” array.
Every time when you call the function , it use the “testArr” array and not the submitted array.

Don’t need make the “remove” variable. Instead it use the “item”. Give them a new value. It is not bad , just not necessary. :slight_smile:

1 Like

Thank you for taking the time to explain.

I’m sorry but I am still not understanding… :confused:

Could you please write out the entire code so that I can cross reference it to the one I have?

You are not using the array passed as an argument to the function in function nextInLine(arr, item)

Your function would only work if there were an array named testArr and could not be used with any other arrays

let testArr = ['b','d','a','c','f','e'];

function sort1(arr){
  return testArr.pop();

console.log(sort1(testArr)); //f
console.log(sort1(['z','z','z'])); // 'e' not 'z'

Written like this the function will take any array passed to it as an argument.

let testArr = ['b','d','a','c','f','e'];

function sort2(arr){
  return arr.pop();

console.log(sort2(testArr));  // f
console.log(sort2(['z','z','z']));  // z