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 trialZachary Dunn
6,557 Points??qef
??
<!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 2</h2>
<script>
var first = ["The", "quick", "brown", "fox", "jumps"]
var second = ["over", "the", "lazy"];
var saying = first + second.concat("dog");
var shortSaying = saying;
var sayingString = saying;
</script>
</body>
</html>
1 Answer
Marcus Parsons
15,719 PointsHey 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?