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

Having problems with strings

It says to create a string 'statement' with the text of - She said "How's the family? when i make it, it says that i haven't identified the variable 'statement' I have gone over the video 3 or 4 times and i don't know whats wrong, This is what i put. var statement : 'She said' "How's the family?"

2 Answers

Philip Allen
Philip Allen
8,171 Points

Hi Alan

Not sure which tutorial you are referring to but declaring a variable in JavaScript called statement with the string of She said "How's the family?" would be.

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

you need to use the escape character of backslash as the variable contains single and double quotes.

Regards, Philip

I just tried that and is says that i haven't declared the variable statement

Tom Bedford
Tom Bedford
15,645 Points

Hi Alan

You need to escape some of the characters with a slash ( e.g. \ ). It is covered in this video from ~2:50. Due to this, at the moment your string only includes 'she said'.

You also need an equals sign not a colon between the variable name and the string.