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!
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
Chris Harkin1,104 Points
Removing items from arrays Challenge Task 1
Hi can can any one help am stuck on the first challenge question for this video.
"Challenge Task 1 of 2
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. "
The error am getting
Bummer! It doesn't look like you stored the first item from the array in the shipping variable.
var orderQueue = ['1XT567437','1U7857317','1I9222528']; orderQueue.shift(); var shipping = ['1XT567437'];
the 'shift' method removes the first element of the list and returns it.
This is how one does it:
var orderQueue = ['1XT567437','1U7857317','1I9222528']; var shipping = orderQueue.shift();
Also, square brackets are creating a list literal. So when you write ['1XT567437'], you create a list that contains the String '1XT567437'.