Tell us what’s happening:
I can’t understand what to do in the lesson.
I copied the answer from the hint in hopes that I may be able to understand but eventually failed.
Also , Can .push() and shift() be applied on variables as well as arguments?
plz help!
For more info plz click the link below.
Thank You.
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
Thank you for replying
At first I didn’t understand what to write in answer. So I decided to check the answer in the hint . But I didn’t understood that too .
So in short I would like to understand why the answer is so.
After these msg I understood that I didn’t actually understand the applications of the properties properly and was doing wrong so I searched on the net and understood the properties and also cleared the lesson .
Thank you for the help.
Congratulations on figuring it out! Trying to find what to research and how to research it is one of the challenges that continues through your coding life.