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

Zoe Xiao
Zoe Xiao
7,195 Points

Is something wrong with this

var statement='She said"How\'s your family?"'; Why doesn't it work?

2 Answers

Hi Zoe,

You have the right idea it's just that your output doesn't match exactly.

You're missing a space after said and you need to change your to the

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

Zoe Xiao
Zoe Xiao
7,195 Points

Thanks Jason You are right!

Dan Mirda
Dan Mirda
3,992 Points

I think you may have missed a few escape characters:

var statement= 'She said \"How\'s your family?\"';

Hope that helps!

Zoe Xiao
Zoe Xiao
7,195 Points

Thank you Dan as well! Actually it does not matter if you just use a single slash...

That's correct. If you enclose your string with single quotes then you only have to escape single quotes.

Enclosing this string with single quotes requires less escaping than if you had enclosed it in double quotes because then you would have 2 double quotes to escape.