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 trialAlan Hernandez
506 PointsHaving 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
8,171 PointsHi 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
Tom Bedford
15,645 PointsHi 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.
Alan Hernandez
506 PointsAlan Hernandez
506 PointsI just tried that and is says that i haven't declared the variable statement