Escaping Literal Quotes in Strings

Hi good people

Can someone assist me here i can’t seem to figure out where I am going wrong after following the instructions?

const myStr = “I am a “double qouted” string inside “double qoutes”.”; // Change this line

I keep on getting an error
Variable myStr should contain the string:

I am a "double quoted" string inside "double quotes".
1 Like


You need to escape those double quotes inside the string. Otherwise, JavaScript will think you’re opening and closing strings several times!

Check out the MDN documentation on this.

Hope this helps!


You should add backlash \ before the quotes you want to be ignore. If you don’t, they decoder thinks you’re closing the string between the first quotes.

Also, if you want to know if it’s working, pay attention to the color changing as you add backlash before quotes.

Now, when I add backlash before the “double quoted”, look what happen:

So you have to add backlash before all the quotes you want to be ignored and your final string will be as beautiful as ever!


There’s already good pointers above on the more technical JavaScript concept involved, but watch your spelling on the word “quotes” if you changed that as well! I imagine the tests are looking for an exact match so typos won’t work.


Similarly, in Javascript Basics #26, you’re meant to use “” and ‘’ together. I initially changed the inside quotes to be single and left the outside quotes as double, and got an error.

const myStr = "<a href='' target='_blank'>Link</a>";

The lesson expects 4 double quotes and 2 single quotes, so I switched these and got it to pass, but was curious- Should this work in reverse (using double quotes as the outer and single quotes as the inner)? Does it matter which is used for what? Thanks!

1 Like

Almost always it doesn’t matter provided that you’re consistent.

One gotcha you need to beware of is using “” instead of “” – some websites format code to use the curly brackets which look nicer in conversational text but which won’t work in code/

1 Like