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

JS Arrays Challenge

I'm not sure what I'm doing wrong here, it keeps giving the error "Missing the unshift and firstWord variable". Help anyone?

      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 = firstWord.unshift(1);

1 Answer

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

The challenge is asking you to add the firstWord variable to the beginning of saying. saying is an array, so you use the unshift() method on it, and pass the variable you want to add:

saying.unshift(firstWord);