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 Basics (Retired) Storing and Tracking Information with Variables Review Strings, Numbers and Spaces

Winnie Huang
Winnie Huang
871 Points

How to escape the second quote in JS?

Dont' understand what this sentence mean, What should I fill in that blank? Please help me, I would like to know the answer! Thank you.

var text = 'She ____'s the best!';

1 Answer

Julian Aramburu
Julian Aramburu
11,368 Points

Hi!

The problem here is that you have a quote inside a quote...so if you don't "escape" that inner quote, it will work closing your string so in order to avoid that you need to use the escape character that I believe in this case is the backward slash \ ... so doing 'She\'s the best!' the inner quote in "She's" would be part of the string instead of closing it in "She". Hope you find this answer helpful.

Winnie Huang
Winnie Huang
871 Points

Oh! I see!! Just put the backward slash. ha ha ha, now I know how to escape other quotes! Thank you very mush :)