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 trialabdi ali
10,920 PointsThe orderQueue array contains a list of customer orders. Create a new variable named shipping -- remove the first item f
help me
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
oderQueue.shift();
var shipping = ['1XT567437'];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
8 Answers
Marileen Mennerich
1,161 PointsYou are asked to remove the first item and simultaneously save it in your new variable called shipping. It should look like this:
var orderQueue = ['1XT567437','1U7857317','1I9222528']; var shipping = orderQueue.shift();
Daryl Baker
2,044 PointsI feel this question should be altered or taught in the last video on taking a value from the array and putting it into a string, I was unsure you could take the value and move it. least for newbies here :)
Jeremy Kerrigan
12,002 PointsI agree they should have taught us how to insert the value into a new variable using this method. We learned how to remove and add to and from one variable only. I guess they were looking to see if our mind could wrap around the challenge but we can only implement what we have been taught. However I do love the course. Thanks
Matthew Foster
6,736 PointsI agree.
Robert Rydlewski
3,828 PointsI agree with you
Cosimo Scarpa
14,047 PointsYou need simply create a variable with inside the action that you want to run.
Like this.
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
var shipping = orderQueue.shift();
abdi ali
10,920 Pointsthanks it worked
Matthew Costigan
18,319 PointsCorrect - Answer
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
var shipping = orderQueue.shift(0);
Tom Nguyen
33,501 Pointsmy solution:
const orderQueue = ['1XT567437','1U7857317','1I9222528'];
var shipping = orderQueue.shift();
var cancelled = orderQueue.pop();
Samuel Buta
2,403 PointsThanks so much your cades has been working great for me so far, and I would suggest other to use your solutions.!
Arturo Espinoza
9,181 PointsI don't understand how that would work.
var orderQueue = ['1XT567437','1U7857317','1I9222528']; var shipping = orderQueue.shift();
var orderQueue = ['1XT567437','1U7857317','1I9222528']; // I understand this ok
orderQueue.shift(); // I understand this ok
var shipping = //how is the first item saved in shipping?
Marileen Mennerich
1,161 PointsThe .shift() not only removes the first the first item from the queue but also returns it, thus you can assign this return value to the variable.
StJohn Krog
2,578 PointsThe two comments above are correct, but you must watch your spelling as you have spelt order as oder. :)