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

i don't understand this question

On about line 20, add the 'firstWord' variable to the beginning of the array 'saying'.

my answer is this saying.unshift("firstword");

but say this You're missing the 'unshift' method and the 'firstWord' variable.

i create the variable but the system say repeat tag 1 what is the problem ?

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 firstWord = spareWords;
      var lastWord = spareWords;
      saying;
      saying;
    </script>
  </body>
</html>

1 Answer

David Clausen
David Clausen
11,403 Points

You seem to be doing it right, but variables are caps-sensitive. Your answer is:

 saying.unshift(firstword);

which is not the same as

 saying.unshift(firstWord);

firstWord as a capital W in Word, your is a lower case w in firstword.

firstWord vs firstword two different variables, make sense?

Also you casted it as a string which is not a varible but a string called 'firstWord' vs firstWord

this is my first answer but the system say You're missing the 'unshift' method and the 'firstWord' variable.

David Clausen
David Clausen
11,403 Points

Your going to have to paste your whole code. As from here that was your issue. Seeing as that doesn't fix it, I need to see code. Copy and paste what your working on in between

```javascript
//Copy Code in between here
```

this is my code

<!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 firstWord = spareWords.shift(); var lastWord = spareWords.pop(); saying.unshift("firstWord"); saying; </script> </body> </html>

this is the question

On about line 20, add the 'firstWord' variable to the beginning of the array 'saying'.

and system say this

You're missing the 'unshift' method and the 'firstWord' variable.

David Clausen
David Clausen
11,403 Points

I copied your answer and didn't even notice the other mistake. Silly me. I've edited my answer to include that.

You said earlier

my answer is this saying.unshift("firstword");

So the first mistake was firstword capitalize, but I missed the second mistake. You have "" wrapped around the variable. That makes it a string variable that contains the word "firstWord". A variable is without quotes which is

//this is correct without quotes around firstWord
saying.unshift(firstWord); 
//Not 
saying.unshift("firstWord");  

firstWord contains the string "The"
"firstWord" contains the string "firstWord"

My bad for not catching that too.