Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
David Regel
Full Stack JavaScript Techdegree Student 5,504 PointsThe orderQueue array contains a list of customer orders. Create a new variable named shipping -- remove the first item f
The full task is this: "The orderQueue array contains a list of customer orders. Create a new variable named shipping -- remove the first item from the array and place it in the shipping variable."
According to the course, the correct way to solve the task is this:
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
var shipping = orderQueue.shift(shipping);
However, I was wondering what happens when you write the code like this:
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
var shipping
orderQueue.shift(shipping);
According to the Code Challenge, my solution is wrong. Is someone able to explain to me what the result of my solution approach is actually doing? My idea was to create a variable named "shipping" and to use the result of the shift() method as the value of this variable. What happens if you put something inside the parentheses of the shift() method?
1 Answer
Steven Parker
243,318 PointsThe "shift" method does not take an argument. In both your examples the argument you have supplied is being ignored.
But in the second example, you're removing the first item but not storing it anywhere. That's why it does not pass the challenge.
David Regel
Full Stack JavaScript Techdegree Student 5,504 PointsDavid Regel
Full Stack JavaScript Techdegree Student 5,504 PointsThanks! It makes sense now. I just realized that there is also no example for an argument in the shift() method on the Mozilla Developer Network.