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 trialCarla Thomas
Front End Web Development Techdegree Student 16,039 PointsMethods Pt. 1 (Task 1 of 4)
Please explain the correct answer to me (like I'm a 3 year old).
I fully understand the purpose of each method ...however, my answer is still incorrect....I've even added JS books to my library and use resources like w3c tutorials but still find myself not able to pass a seemingly simple challenge like this one.
My answer
spareWords.unshift(firstWord);
firstWord.shift();
The instructions
On line 18, use a method on the 'spareWords' to set 'firstWord' to be first word of the 'spareWords' array whilst simultaneously removing it from the beginning of the array.
The code
<script>
var spareWords = ["The","chimney","sweep's","dog"];
var saying = ["quick", "brown", "fox", "jumps", "over", "the", "lazy"];
var firstWord = spareWords;
var lastWord = spareWords;
saying;
saying;
</script>
4 Answers
Carla Thomas
Front End Web Development Techdegree Student 16,039 PointsUnfortunately, I guessed and got the answer correct. I will definitely return to review this unit.
var firstWord = spareWords.shift();
spareWords.unshift(firstWord);
Jim Clark
13,319 PointsI got stuck here too. This is the first challenge I have ever needed to use the forums and external resources on. I still don't understand what they are asking for but glad you stumbled upon the answer!
Wayne Leyden
4,995 PointsI second you this is a difficult question to understand.
Jamie Hinojosa
6,982 PointsI'm not sure why but this answer was correct for me: var firstWord = spareWords.shift();
Francesco Vittorio Beninato
3,624 PointsFrancesco Vittorio Beninato
3,624 PointsYeah, me too! I have still no idea why your solution worked! I would have nave come up with this solution!
Thanks Carla!