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 trialLance Volk
Full Stack JavaScript Techdegree Student 1,628 PointsMy code checks out in the console, but it says I didn't pass the challenge, both arrays check out.
When checking the arrays, shipping and orderQueue in the console, they are as they were asked to be. Am I missing something? I have removed the first item from the orderQueue array and put it into the shipping array.
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
var shipping = [orderQueue.shift()];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! The brackets around the orderQueue.shift();
are unnecessary. Try removing those and give it another go. Hope this helps!
Lance Volk
Full Stack JavaScript Techdegree Student 1,628 PointsThanks Jennifer, I thought that arrays always had to be in brackets, it still worked, but I'm all for less code. Thanks again, Lance
Jennifer Nordell
Treehouse TeacherRight, except that shipping isn't an array. Shipping is holding an element that you shifted out of an array. The shift method is used directly on the array
If you had wanted to add it to an array named shipping then you could chain a shift and a push to push it into a new array.
Lance Volk
Full Stack JavaScript Techdegree Student 1,628 PointsMy mistake Jennifer, I thought I was creating another array called shipping instead of just a variable. Thanks for the clarification. Lance