Tell us what’s happening:
Describe your issue in detail here.
/* In the challenge tests on the very bottom left side of the website screen , the last test reads: After nextInLine (testArr, 10) , testArr [4] should be 10. Community! can you please help me understand or explain step by step how the nextInLine function is processing this function call when these values are passed as arguments into the function. Thanks for your help in advance. */
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
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15
Thanks for the reply but this line just removes and returns the first element in the testArr array and it works just fine. That’s not what I as asking but thanks again for the fast reply.
Its processing them the same way it was processing the other function calls. It just that its using a variable storing an array, rather then an array literal.
The testArr[4] part is just indexing into that array. And at index 4 there should be a 10, because you pushed a 10 and removed 1 with the function call.
I get the testArr {4] part. What I’m struggling with is how is it processing
the (testArr , 10) and testArr{4} simultaneously to get a return value of 10??
thanks for the reply.
I’m assuming u mean
the: let testArr = [1, 2, 3, 4, 5] as the variable it’s creating that has the test array or did u mean the -arr variable in the function?