Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Arrays Methods: Part 3



<!DOCTYPE html>
<html lang="en">
    <title> JavaScript Foundations: Arrays</title>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
    <h1>JavaScript Foundations</h1>
    <h2>Arrays: Methods Part 2</h2>
      var first =  ["The", "quick", "brown", "fox", "jumps"]
      var second =  ["over", "the", "lazy"];
      var saying = first + second.concat("dog"); 
      var shortSaying = saying;
      var sayingString = saying;

1 Answer

Hey Zachary Dunn,

You are a little bit off on your concatenation, but don't worry, because I will help ya! First off, when we concatenate two or more arrays, we just use that "concat" method. There's no need for any + sign as this only applies to strings or string variables.

So, the first part of Task 1 should look like:

var saying = first.concat(second);

But, we're not done yet, because the challenge wants us to add the word "dog" to the concatenation of the arrays. Well, that's no problem, because all you have to do to add in more strings/arrays, is to add a comma between whatever we want to add. So, since we want to add "dog" to the end, all we gotta do is:

var saying = first.concat(second, "dog");

The saying variable will now look like: ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"]. Does that make sense?