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 trialWilliam Doring
Courses Plus Student 4,388 PointsI get marked wrong but the correction matches my output.
For the first problem in the following exercise, I changed the line to var saying = first.concat(second +",dog"); this produces the error Bummer! was expecting 'the,quick,brown,...' but got 'the,quick,brown,...' I copied and pasted the strings in the correction into a text editor and they are identical. What am I missing?
1 Answer
Jonathan Grieve
Treehouse Moderator 91,253 PointsI think the key is in looking at what is in the original string. If for example in the string it ends with a comma you won't need it in your concatenaton. Would this be what you're looking for?
Hope this helps. :)
William Doring
Courses Plus Student 4,388 PointsWilliam Doring
Courses Plus Student 4,388 PointsThe comma is missing if I concatenated with that syntax so that's not it. There's something with the way the site is testing the syntax, methinks.
I am able to pass with var saying = first.concat(second, "dog");
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsI think you've stumbled on the right answer actually :) The plus (+) operator would be a way to concatenate 2 hancoded strings
so
var concat = "this is a string" + " and this is also " + "a string";
is just as valid concatenation as
first.concat(second, "dog");
The difference being that concat is a built in JavaScript function. :)