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

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Removing Items from an Array

Claire Parks
PLUS
Claire Parks
Courses Plus Student 1,901 Points

orderqueue array

I'm struggling to understand why this answer isn't correct. The message I get is that I'm not storing the item in the shipping variable.

script.js
var orderQueue = ['1XT567437','1U7857317','1I9222528'];
orderQueue.shift();
var shipping = [];
shipping.push('1XT567437');
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

Antonio De Rose
Antonio De Rose
20,885 Points
var orderQueue = ['1XT567437','1U7857317','1I9222528'];

orderQueue.shift(); // this line is correct, but the element which has removed had to be put in a variable shipping.
var shipping = []; //this is just an empty array, which does not have value, it does not take value from any action.
//it has to be a variable as it is storing only one value, and not an array.

//you will have to make the above 2 lines as one line, the element removed to be put into var shipping
//you are so close, give it a last try

shipping.push('1XT567437');//remove this line completely, as the task had not asked you to add an element.
blake guyan
blake guyan
8,297 Points

I love that you didnt just give him the answer. bonus points for you!

Claire Parks
PLUS
Claire Parks
Courses Plus Student 1,901 Points

Oh my goodness! I feel silly. Thank you so much for your help!