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 Foundations Arrays Methods: Part 1

Mark Lovett
Mark Lovett
15,853 Points

My answer works fine in the console but is not accepted??

var firstWord = spareWords.unshift('firstWord'); 
spareWords.shift();

2 Answers

Erwin Meesters
Erwin Meesters
15,088 Points

You can use the shift() method to pull the first element off of a given array and return it. In this case you can use the shift() method on the spareWords array to pull the first element off, return it and assign it to the variable firstWord. Your code should look something like this: var firstWord = spareWords.shift();

Mark Lovett
Mark Lovett
15,853 Points

Thank you Erwin. I didnt understand the question.