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

JavaScript JavaScript Foundations Arrays Methods: Part 1

JavaScript 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.

 <script>
      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");
      saying.unshift(firstWord);
      saying;
    </script>

Now it works...

3 Answers

Your 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;

Did you add the quotes to "firstWord"?

You don't need the quotes for a variable!!

Adam, thanks for the confirmation and fixing the markdown. Dodgy Gremlins...

Your welcome. Haha they are taking over.