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

im not understanding the reqiurements of this question

failing to answer the question

index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title> JavaScript Foundations: Arrays</title>
    <style>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
      }
    </style>
  </head>
  <body>
    <h1>JavaScript Foundations</h1>
    <h2>Arrays: Methods Part 1</h2>
    <script>
      var spareWords = ["The","chimney","sweep's","dog"];
      var saying = ["quick", "brown", "fox", "jumps", "over", "the", "lazy"];
      var spareWords = unshift(firstWord);
      var lastWord = spareWords;
      saying;
      saying;
    </script>
  </body>
</html>

1 Answer

Hey Prudence,

It looks like you changed around that third line in the script quite a bit. The variable is firstWord and you are setting firstWord to the first item in the array spareWords. The way you have your code now would reset spareWords to be some other value which is not what we want. Instead, we want to use the shift method which will take the first item out of an array, store it into the variable, and remove it from the array. Your code should look like this:

      var spareWords = ["The","chimney","sweep's","dog"];
      var saying = ["quick", "brown", "fox", "jumps", "over", "the", "lazy"];
      var firstWord = spareWords.shift();

Keep that in mind for the next set of tasks, as well!