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

Stephanie Varvar
Stephanie Varvar
4,273 Points

I don't understand why this isn't the answer. var statement = 'She said \"how\'s the family?\"';

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

strings.js
var statement = 'She said \"how\'s the family?\"';

2 Answers

Chris Slack
Chris Slack
28,500 Points

Escaping double quotes while within single quotes (and vice versa in JavaScript) is not necessary. However, this won't make you fail because escaping them is also valid, so this will still pass.

The real reason you are not passing is that you are not capitalizing the "H" in "How". I cut and pasted your answer in and just changed that and you pass.

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

Just a small detail, not really coding related per se, but when writing code the output can be just as important as the back end code, clients expect perfection and so does Treehouse it seems :-)

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

The challenge answer checking is probably looking for something very specific.

Personally I don't see why that should fail. It's a legitimate way of displaying the text with the escape characters as they are.

But I passed the challenge like this. I used double quotes except for the the character where the apostrophe is needed.

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