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 trialChris Dabatos
1,170 PointsWhats the answer for this?
const orderQueue = ['1XT567437','1U7857317','1I9222528'];
orderQueue.shift()
const shipping = [0];
shipping.unshift(0);
1 Answer
Peter Vann
36,427 PointsHi Chris!
This passes both tasks:
const orderQueue = ['1XT567437','1U7857317','1I9222528'];
const shipping = orderQueue.shift(); // Task 1
const cancelled = orderQueue.pop(); // Task 2
Keep in mind:
1) shift removes an item from the FRONT of the array
2) unshift adds an item to the FRONT of the array
3) push adds an item to the BACK of the array
4) pop removes an item from the BACK of the array
And all four are functions, so you have to call them with ().
Also, after both operations, orderQueue === ['1U7857317']; // The middle value only, because the other values were removed.
(=== is equal to, of course)
I hope that helps.
Stay safe and happy coding!