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!

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



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

Im a little confused??????

14 Answers

Code Challenge: In 'strings.js' file define a string called 'statement' with the text of - She said "How's the family?"

The reason it keeps telling you 'Variable is not defined' is because you used 'statement1' as your variable. The variable you should use is 'statement'

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

Hope that helps Tony

Hey Tony, I think this is what you're looking for

var statement1 = 'She said, "How\'s the family"';

Finally Got it!! Thanks Armondo..

Why are you confused Tony?

Marcus Tisäter
Marcus Tisäter
4,886 Points

Hmmm.... When you want to input ' into the sentence you have to input \, also you can't use "" in a "" string quote. Single quotes are recommended using instead. Look at this example:

var statementTony = 'He said "This is Tony\'s"';

Now try this with you're variable :)

Good luck

var statement1 = "She said, How's the family"; it continues to say variable not defined {

var statementTony = "She said, How\s the family";

Still can't seem to get through?

Try: var statement1 = "She said, \"How's the family?\"";

Since you're using double quotes (") for the string, the single quotes don't need to be escaped with a \. You do, however, need to escape the double quotes so that they aren't misconstrued as the end of the string declaration.

If you're setting this in the console (e.g. in Chrome Dev Tools), you'll get immediate feedback of undefined, but then if you call statement1 in the console, it'll show you the value has been set properly to "She said, "How's the family?"". The extra double quotes on the front and back indicate that it's a string and not another value. To prove this, run typeof(statement1) in the console after you've declared the variable and you should get "string".

Hope that helps.

var statement = "She said, How's the family?\""; and var statement1 = "She said, \"How's the family?\""; tried both of these and more I'm not sure whats wrong!!?

Maybe it'll help to know what you're trying to accomplish.

You can use either one.

var statement1 = 'She said, "How\'s the family"';
var statement2 = "She said, \"How\'s the family\"";

Sorry Armondo still don't work for eaither one. It say's you haven't defined the "statement" variable

I was confused by you're question. If you're trying to pass the code challenge the correct 'statement' is

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

But since you wrote var statement 1 i thought you just wanted clarification.

Omh MG
Omh MG
19,233 Points

Having the same issue here, however it's telling me "Bummer! You've the string is the incorrect value remember to use \ before the " or '."....

My code for this challenge is var statement = 'She said, "How\'s the family"';

Help, anyone? This should be working

Omh MG
Omh MG
19,233 Points

It's working now.

Vincenzo Lanza
Vincenzo Lanza
6,185 Points

In my case this code is not correct, why? var statement = 'She said, "How\'s the family"';