Tell us what’s happening:
Hi
This lesson threw me a bit. I’m finding it a bit difficult at the minute but Ill stick with it. in the code below we have used the arr. And there is a variable declared var testArray.
So I was setting arr = test array within the function but getting error messages.
So I watched the video.
I don’t get how it seem that it knows that arr and testArr are the same value but how?
There is nothing to link the 2. In fact I thought with out giving arr some value the code would not be able to carry out any process with out it having a definition.
Your code so far
function nextInLine(arr, item) {
// Only change code below this line
arr.push(item);
return arr.shift(0);
return item;
// 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.63
.
Challenge: Stand in Line
Link to the challenge: