How do I do this lesson?

Tell us what’s happening:
I have checked the hints and other forums posts about this challenge and I dont understand why this isnt right. I don’t understand what it means.

Your code so far

var myStr = I am a \"double quoted"\ string inside \"double quotes\".

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36

Challenge: Escaping Literal Quotes in Strings

Link to the challenge:

Your second \ should be before your " not after.

And all your string should be inside “”

Yes, to put it another way, there are a few ways to get double quotes. One is to wrap the whole thing in a single quote:

const myWifeSaid = 'She said, "We need milk."'

JS understands that because the quote marks are different than the quote marks inside the the string.

That is not what you were asked to do.

You were asked to use double quotes for everything. JS doesn’t know if the ones inside the quote are part of the quote or mark the beginning or end of a string. That’s OK, we can “escape” the inner quote marks so JS knows that they are part of the string:

const myWifeSaid = "She said, \"We need milk.\""

These two strings will produce the same output.

Does that make sense?

Like this?

var myStr = "I am a \"double quoted\" string inside \"double quotes\".

All your string should be inside ", you correctly corrected the beggining " but you’re still missing the closing "

I’m still really confused, what should the closing be?

In javascript when you want to declare a string variable you should enclose it in “”

var myString = "My String";

In your code you have the starting " but you forgot the final one after your .

var myStr = "I am a \"double quoted\" string inside \"double quotes\". <- missing closing "

it can be easy to miss when you have a string with lots of quotes " like this one, what helps me is to put the opening and closing " before I start to write my string.

you also forgot the ; at the end

hope i have explained it well

Oh, I missed the last quotation mark and semicolon.
Like this?

var myStr = "I am a \"double quoted\" string inside \"double quotes\"".;

The period . is part of your string and should be inside of the closing "

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.