Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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();