Basic JavaScript - Stand in Line

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

what am I doing wrong?
function nextInLine(arr, item) {
  // Only change code below this line
  testArr.push(6);
  arr.shift()
  
  return item;
  // Only change code above this line
}

// Setup
let 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));

console.log(nextInLine([10, 12, 13], 3))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Stand in Line

Link to the challenge:

This line isn’t correct. Can you see why?
Also, the challenge asks you to return the removed item, not the item you add to the array.

Okay i have seen the problem

arr.push(6)
return arr.shift()

I tried but still wasn’t working

Why are you pushing the value 6 into the array?

adding a number to the array. I don’t see how else to do it

  • what are you returning ?!
  • what is testArr

question: if you are returning that “item” then why are you doing all those “steps” in that functions?

happy learning :slight_smile:

You are supposed to add item to the array.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.