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
  dave fernandez
531 PointsI don't get \"" .. I understand what it does but why doesn't the 2nd quote interfere I guess ?
confused
andren
28,558 PointsYou don't need to feel bad, it's pretty common to get a bit confused when it comes to using double quotes within double quoted strings, especially when string concatenation (combining strings with +) is involved.
It can be hard to visually decipher in the beginning, but like most things it becomes easier as you see more examples of it and get used to using it on your own.
1 Answer
andren
28,558 PointsInterfere with what? I'm not sure I understand the question, the second quote mark simply marks the end of the string.
When you use double quotes to start a string JavaScript will be looking for another double quote to indicate that the string is finished. If you want to include a double quote within the text of the string without making JavaScript think the string is finished you have to escape it with the \ symbol.
That means that in the example you provide the first double quote will be treated as pure text, which is inserted in the string, while the second will be treated as a marker that the string is finished. That is the intended outcome.
dave fernandez
531 Pointsdave fernandez
531 PointsI feel sheepish smh .. ty so much Andren for elaborating in detail... I was confused and didn't realize the text quotes were in final staement on purpose etc... and they spacing for ex: on either side also got me for tad \"" + completeName + "\"