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 3

Bart Pit
Bart Pit
1,150 Points

don't understand what I need to do in task 1

Question is:

On line 18, set the variable 'saying' to the concatenation of the 'first' and 'second' arrays with the word "dog".

var first =  ["The", "quick", "brown", "fox", "jumps"]
var second =  ["over", "the", "lazy"];

I know I need to concat the two like so:

var saying = first.concat(second);

But what do I need to do with 'dog'? Push it on the end of the new saying array? Tried that, didn't work. Tried to join the saying array with 'dog' as separator. Didn't work. When I check the code with only the concat of the two arrays, it responds with that it expects an array like:

"The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"

Well, saying.push('dog') would do that, but it's rejected :( Please help.

2 Answers

Kevin Kenger
Kevin Kenger
32,834 Points

Hey Bart,

It just wants you to do exactly what you did to concatenate the two variables.

Like this:

var first =  ["The", "quick", "brown", "fox", "jumps"]
var second =  ["over", "the", "lazy"];
var saying = first.concat(second).concat("dog");
Bart Pit
Bart Pit
1,150 Points

Ahaa, makes sense now. Thanks! :)