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

Array shift and unshift help needed

I am stuck with this code challenge. It looks pretty simple but the "Bummer!" say's otherwise.

10 Answers

"The"

you're setting the variable firstWord to be whatever is the first element of the array spareWords, so .shift() returns that first element (in this case "The") and removes it from the array, so now firstWord = "The"

Thank you for this. I was struggling to understand the wording on the first question, but as soon as you restated it I sailed right through!

Chase Lee
Chase Lee
29,275 Points

Could you give a link to the code challenge?

Chase Lee
Chase Lee
29,275 Points

Thanks. Just a minute.

I know that unshift places the string on the front of the array and shift takes the string away. I just don't understand what answer is required for me to write the correct code.

Hey Chase, did you manage to find any hints as to complete the challenge?

btw which stage (1-4) are you having specific trouble with? Just went through it and everything is working fine. In addition to .shift() and .unshift() it is also referencing .pop() and .push() methods

Hi it's stage 2, using .shift() and .unshift()

sorry I meant task... not stage. I apologize.

Would you be able to explain which word is going to the front of the array? Is it "firstWord" or "The"

Also, w3schools.com is a great addition imho to what we can learn here at treehouse. I much prefer treehouse for learning a new topic and practicing it, but I really like w3schools as a reference later on once I feel like I've "seen" it enough to comfortable but maybe not fluent.

Oh yes I got it wrong too. It is stage 4 Array challenge task 1.

Thanks James. I was getting confused with what the question was asking me to do. I was starting with .unshift() because I thought the question was asking me to place 'firstWord' to the beginning of the array.

Completed all 4 tasks now. Thanks again.

Awesome!

To be completely honest... the javascript deep dive has been the absolute toughest for me to get through. I really appreciate you asking this question because it makes me feel like maybe I'm beginning to understand how js works...