Basic JavaScript - Stand in Line

Tell us what’s happening:
Describe your issue in detail here.
I don’t understand what the last test requires. I mean this instruction: After nextInLine(testArr, 10), testArr[4] should be 10
Your code so far

function nextInLine(arr, item) {
  // Only change code below this line
  
  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));

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 11; TECNO PR651E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.85 Mobile Safari/537.36

Challenge: Basic JavaScript - Stand in Line

Link to the challenge:

All that means is that testArr[4] (as in the array element at index 4 of testArr) should equal 10, after you have invoked nextInLine(testArr, 10).
Essentially, the function should simply add to the array the number given as the second argument, and then remove whichever element is first in the array (i.e. at index 0).

Alright, got it. Thanks a bunch

It is like a queue:
Element passed to the function will be the last element added to the array (the queue) and for every element added, an element has to be removed (from the beginning of the queue)

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