Tell us what’s happening:
Describe your issue in detail here.
Hi, my question is how is arr related to testArr? we are pushing to arr in the function but it pushes to testArr, i dont see how they are linked?
**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
const 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
If the above answer does not clarify your doubts, when we called a function with parameters we are to assign arguments to the function so that those arguments will assign as the parameters of the function when we called it.
Here function,
nextInLine(arr, item)
has two parameters which are arr and item. When we called the function with arguments testArr and 6 the values of the arguments will be assigned to the parameters inside the function. So, now inside the function