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 trialashique desai
3,662 PointsUnable to add a removed array in a variable
i am have successfully removed the first array from the orderQueue variable as asked (At-least i am assuming it). But i am unable to add it to the var shipping. Can somebody please help?
```javaScript
var shipping ;
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
orderQueue.shift();
orderQueue.shift() = shipping;
```index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Ashique,
There's a few problems here.
If you call the .shift()
method 2 times then you'll end up removing 2 items from the front of the array.
The other thing is that you have your assignment statement reversed.
The variable should be on the left side and the value that's being assigned is on the right side of the equal sign.
var shipping = orderQueue.shift();
That code is saying, "Remove the first element from the array and then assign that value to the shipping
variable."
ashique desai
3,662 PointsThanks. That worked like a charm!
Bryan Guillen
2,429 PointsBryan Guillen
2,429 PointsFor some reason I implemented that solution myself.
var shipping = orderQueue.shift();
However it is still giving me this message:
"It doesn't look like you stored the first item from the array in the shipping variable."
Any suggestions?
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsDid you put that on the second line?
It worked for me when I pasted it in.
Post the full code that you have if you're still stuck and I'll see if I can figure out what's wrong.
Bryan Guillen
2,429 PointsBryan Guillen
2,429 PointsHey Jason,
Yes I posted it on another line. After refreshing it, it finally worked. A little odd. I had the same code.
After getting it wrong once, I tried it again and it finally worked. !