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

Chris Scott
Chris Scott
7,673 Points

JavaScript Foundations - Arrays - Methods Part 3 - Code Challenge

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

"foo.concat" isn't working as expected.

"var first.concat(second, "dog");" passes challenge 2 but when I try "saying" it returns this ["The", "jumps", "over", "the", "lazy", "dog"] in both Chrome Console and JSBin.

2 Answers

Ian Pilsner
Ian Pilsner
5,174 Points

I used this method, and it gave me the same array, it is wrong? i know the challenge didn't pass me but it outputted the same array string.

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

Chris Scott
Chris Scott
7,673 Points

I believe you're supposed to pass just the two variables, instead of a concatenated one using the operator.

My solution passed the test just doesn't work in practice.