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 trialVictor Mendizabal
Courses Plus Student 2,059 PointsWhat is the problem with this simples line?
var statement = "She said \"How\'s the famyly?\"";
4 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Victor,
All that was wrong was a typo. You spelled family wrong.
It's not necessary to escape the single quote when wrapping your string in double quotes but it's not wrong to do so.
In this case, since the string contains 2 double quotes and 1 single quote you would have less escaping to do if you wrapped the string in single quotes. Then you only have to escape the 1 single quote.
var statement = 'She said "How\'s the family?"';
Aaron Graham
18,033 PointsIf you are using double quotes to define your string, you don't need to escape a single quote. This would work:
var statement = "She said \"How's the family?\"";
Tristan Gaebler
6,204 PointsI don't think you can have two double quotes together at the end like that.
Dave McFarland
Treehouse TeacherYou can have the double quotes together at the end of the string, as long as the first double quote is escaped like this \""
. The escape character -- \
-- tells the browser to treat the "
that follows it as just a regular character, and not as the end of the string.
Tristan Gaebler
6,204 PointsThanks Dave!
Victor Mendizabal
Courses Plus Student 2,059 PointsThanks guys! Everything went better than expected =) The problem was actually the misspelled "family".