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 Strings Basics

What is the problem with this simples line?

var statement = "She said \"How\'s the famyly?\"";

4 Answers

Hi 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
Aaron Graham
18,033 Points

If 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?\"";

I don't think you can have two double quotes together at the end like that.

Dave McFarland
Dave McFarland
Treehouse Teacher

Hi Tristan Gaebler

You 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.

Thanks Dave!

Thanks guys! Everything went better than expected =) The problem was actually the misspelled "family".