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
jasondasilva2
2,817 PointsMethods Part 1 Problem.
Hello,
I can't seem to pass the first step in the "Methods: Part 1 Code Challenge"
Basically I've added this code:
var firstWord = spareWords.unshift("firstWord");
var firstWord = spareWords.shift();
by my understanding of the video this should make "firstWord" the first word and then remove it with the shift function?
Thanks in advance,
Jason.
4 Answers
jasondasilva2
2,817 PointsHi Sreng,
Thanks for the feedback, unfortunately it seems I have forgotten how to declare two different methods in one line, Im sure I know it but I can't seem to figure it out!
Thanks.
jasondasilva2
2,817 PointsNope, I changed the code so it fits onto one line but it's still wrong:
var firstWord = spareWords.unshift("firstWord"); spareWords.shift();
The error I get is: "Bummer! The 'firstWord' should be the string of 'The'. It should be shifted from the 'spareWords' array."
what Am I doing wrong?
J.
Sreng Hong
15,083 PointsOn the first task, you have nothing to do with unshift() method.
On line 18, it should be like this:
var firstWord = spareWords.shift();
shift() method will take out the first element of the array spareWords and put it into variable firstWord
Sreng Hong
15,083 PointsHi Jason,
The question is:
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.
All you have to do is modify the line 18 and you can use the method shift() to solve this problem.
Good luck.
Sreng Hong
15,083 PointsSreng Hong
15,083 PointsSo you got it, right?