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 trialEric Flowers
9,472 PointsJavaScript Methods 1 Challenge, task 3 of 4
Challenge is asking: "On about line 20, add the 'firstWord' variable to the beginning of the array 'saying'." My code:
var spareWords = ["The","chimney","sweep's","dog"];
var saying = ["quick", "brown", "fox", "jumps", "over", "the", "lazy"];
var firstWord = spareWords.shift();
spareWords.unshift("firstWord");
var lastWord = spareWords.pop();
sparewords.push("lastWord");
//my solution:
saying.unshift(firstWord);
saying;
feedback from challenge:"Bummer! There's something wrong with your 'saying' array." I don't understand this.
3 Answers
Adam Sackfield
Courses Plus Student 19,663 PointsYour code is correct from what I can tell as I just passed with the same. I will paste what passed below so you may check. But think you may need a refresh and try again. I blame the gremlins for this one. Also I edited your post for correct markdown, if you click edit you can see how it is formatted now.
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;
Giovanni CELESTE
20,961 PointsDid you add the quotes to "firstWord"?
Adam Sackfield
Courses Plus Student 19,663 PointsYou don't need the quotes for a variable!!
Eric Flowers
9,472 PointsAdam, thanks for the confirmation and fixing the markdown. Dodgy Gremlins...
Adam Sackfield
Courses Plus Student 19,663 PointsYour welcome. Haha they are taking over.
Eric Flowers
9,472 PointsEric Flowers
9,472 PointsNow it works...