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
Beth Stranz
3,400 PointsHow do I complete part 1 of this challenge?
http://teamtreehouse.com/library/javascript-foundations/arrays/methods-part-3-2
Challenge question says: ''Challenge Task 1 of 3βOn line 18, set the variable 'saying' to the concatenation of the 'first' and 'second' arrays with the word "dog"."
<script>
var first = ["The", "quick", "brown", "fox", "jumps"]
var second = ["over", "the", "lazy"];
var saying = first;
var shortSaying = saying;
var sayingString = saying;
</script>
So I changed line 18 to: var saying = first.join(' ') + ' ' + second.join(' ') + ' dog';
This returns the correct phrase "The quick brown fox jumps over the lazy dog".
Is this a bug? b/c all I get are error messages, such as: "Bummer! There was an error with your code: TypeError: 'undefined' is not a function (evaluating 'window.saying.join(" ")')"
(window does not even appear anywhere in the code...)
(PS. Does anyone know how to add an image here from my desktop?)
2 Answers
Beth Stranz
3,400 PointsHere is the answer:
var saying = first.concat(second,"dog");
You can read more here: https://teamtreehouse.com/forum/methods-part-3-challenge-task-1-of-3-on-line-18-set-the-variable-saying-to-the-concatenation-of-the-first-and-second-arrays-with-the-word-dog
Jon Benson
12,168 PointsHi Beth,
Don't know if you are still working on this You don't need to use the first.join operator. Declare the variable as a concatenation of the two arrays, which are already labeled, and concatenate them with dog. Hope this helps.
Jon Benson
12,168 PointsI don't think I explained this well. Sorry, I'm just a student too. What I meant was when you join your arrays , all the strings were separated and you just need to use a single join. Ugh, I need to practice explaining versus just writing the answer. sooo i'm trying!