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
Retrieving removed variable for New Array
var orderQueue = ['1XT567437','1U7857317','1I9222528']; var shipping = ; var firstItem = orderQueue.shift(); shipping.push(firstItem);
I'm in the Code Challenge and not sure why the 'firstItem' variable I created isn't functioning when I try to use it to add to my new 'shipping' array . What am I missing?
My error is "It doesn't look like you stored the first item from the array in the shipping variable."
Am I able to use the array storing property as the value of a new variable? Or am I just executing it incorrectly?
Your first code is technically correct and works as expected. But for challenges, you should only do what you're asked to do. You're only asked to create one variable, not two, so that's why the challenge won't let you pass.
Also, in your 2nd set of code, even though this works, too, it's unnecessary to include the brackets because the
shift method returns an array (in circumstances such as this) so you don't need to explicitly define it as an array by using brackets.
This is the simplest solution:
var orderQueue = ['1XT567437','1U7857317','1I9222528']; var shipping = orderQueue.shift();