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 trialeddielsanchez
11,233 PointsMethods part 1 Task 3
I can't get past this question. It's asking me "On about line 20, add the 'firstWord' variable to the beginning of the array 'saying'."
My code below:
<script>
var spareWords = ["The","chimney","sweep's","dog"];
var saying = ["quick", "brown", "fox", "jumps", "over", "the", "lazy"];
var firstWord = spareWords.shift();
var lastWord = spareWords.pop();
saying .unshift(firstWord);
saying .unshift(lastWord);
</script>
Any help is appreciated.
2 Answers
Hugo Paz
15,622 PointsIts because under it you have this line saying.unshift(lastWord);. just comment it out like this //saying .unshift(lastWord); and it should pass.
eddielsanchez
11,233 PointsThanks! It was conflicting with the previous task. It worked after commenting it out.
Hugo Paz
15,622 Pointssaying.unshift(firstWord); You had a space there.
eddielsanchez
11,233 PointsIt's still giving me an error even after I closed the space. It returns: Bummer! There's something wrong with your 'saying' array.
Phil Jones
13,727 PointsPhil Jones
13,727 Pointssaying .unshift(firstWord);
I got rid of the space you had between "saying" and ".unshift(firstWord);" . . . and it passed.