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 trialRichard Glover
10,068 PointsArray shift and unshift help needed
I am stuck with this code challenge. It looks pretty simple but the "Bummer!" say's otherwise.
10 Answers
James Conner
9,821 Points"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"
Chase Lee
29,275 PointsCould you give a link to the code challenge?
Richard Glover
10,068 PointsChase Lee
29,275 PointsThanks. Just a minute.
Richard Glover
10,068 PointsI 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.
Richard Glover
10,068 PointsHey Chase, did you manage to find any hints as to complete the challenge?
James Conner
9,821 Pointsbtw 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
Richard Glover
10,068 PointsHi it's stage 2, using .shift() and .unshift()
James Conner
9,821 Pointssorry I meant task... not stage. I apologize.
Richard Glover
10,068 PointsWould you be able to explain which word is going to the front of the array? Is it "firstWord" or "The"
James Conner
9,821 PointsAlso, 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.
Richard Glover
10,068 PointsOh yes I got it wrong too. It is stage 4 Array challenge task 1.
Richard Glover
10,068 PointsThanks 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.
James Conner
9,821 PointsAwesome!
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...
Lindsey B.
5,259 PointsLindsey B.
5,259 PointsThank 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!