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 trial


use the array method, Remove the last item from the orderQueue array and store it in the variable cancelled.

The question was "Now create a new variable named cancelled. Remove the last item from the orderQueue array and store it in the variable cancelled. Use the array method you learned in the last video for this challenge."

I have completely the challenge. What I have done with the code is

var orderQueue = ['1XT567437','1U7857317','1I9222528'];

var shipping =[];

var cancelled = [];



I do not see any thing to store in the variable "cancelled" without the method function got me suspect because it does not make any sense at all.

if I put the var cancelled = [2]. it will be store of array method...

Do you have any idea to put in the var cancelled inside the array?

Is there possible?

var cancelled =[ orderQueue.pop() ];

4 Answers

This is how I simplify this code challange:

var orderQueue = ['1XT567437','1U7857317','1I9222528'];

var shipping = orderQueue.shift();
var cancelled = orderQueue.pop();
Dave McFarland
Dave McFarland
Treehouse Teacher

Hi Brian van Vlymen

Looks like you've found a bug in the code challenge. Your solution shouldn't have passed. I've updated the challenge to fix this problem.

The challenge is asking you to store the first item from the array into the shipping variable. You would use the .shift() method to do that. It returns the first value from the array. For example, say you had an array like this:

var a = [1,2,3];

And you want to get the first item from that array and store it in a variable named first. You'd do this:

var first = a.shift();

Hope that helps.

Sean T. Unwin
Sean T. Unwin
28,690 Points

Can you post a link to the challenge as I don't recall which course this is from?

Does cancelled need to be an array?

If 'yes', then cancelled.push(orderQueue.pop()); -- remove last item from array orderQueue and store in an array.

If 'no' then cancelled = orderQueue.pop(); -- remove last item from array orderQueue and store in a regular variable.

The challenge fixed the bug. Those are related challenge is http://teamtreehouse.com/library/javascript-loops-arrays-and-objects/tracking-multiple-items-with-arrays/removing-items-from-an-array.

Thank you Dave McFarland for your quickly fixed bug.