Basic JavaScript - Escaping Literal Quotes in Strings

Tell us what’s happening:
Describe your issue in detail here.
Please tell me what is wrong with my code below because i have tried everything and is still not working
Your code so far
const myStr = “I am a"double quoted"string inside "double quotes".”; // Change this line

const myStr = "I am a\"double quoted\"string inside \"double quotes\"."; // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Escaping Literal Quotes in Strings

Link to the challenge:

This string displays as "I am a"double quoted"string inside "double quotes"."

Can you see what the issue is?

I have but then i have tried to rewrite the code and is not working
please give me a hint on how to write the correct code
Thank you

Your code was almost correct. You just didn’t allow for spaces between some of the words.

I have adjusted the spaces and It still did not work

Can you show your updated code please?

const myStr = “I am a " double quoted "string inside " double quotes ".”; // Change this line

Why have you removed the backslashes?

const myStr = “I am a " double quoted "string inside " \double quotes ".”; // Change this line

The first code you posted was almost correct. You need to follow the challenge instructions and use backslashes to escape all of the quote marks inside the string correctly. You did this all correctly in your first code. The only issue was that you didn’t put spaces between some of the words.

1 Like