Where did this array get in the function?

Everything is understood, except, what causes this var testArr to be involved with the function nextInLine? After looking at these four lines of code for about 30 minutes I’ve finally come to the conclusion that I have lost my mind. Please, please somebody help me understand this.

  **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 (X11; CrOS x86_64 13597.94.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.186 Safari/537.36.

Challenge: Stand in Line

Link to the challenge:

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