Regarding the lesson "Escaping Literal Quotes in Strings"

Tell us what’s happening:
I am stuck at this lesson where it is said to use backslashes to assign a string to the myStr variable so that if it were to be printed to the console, I would see:

I am a “double quoted” string inside “double quotes”.

When I run the test it says - Variable myStr should contain the string: I am a “double quoted” string inside “double quotes”.

Is there anything I am doing wrong or there is some kind of bug in the software? whatever the reason be I need to pass the lesson to move on to the next one.

Please help.

Your code so far

var myStr = “I am a “double qouted” string inside “double qoutes”.”;

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-stringsPreformatted text

Hi @Numerang

Just re-read your initial post about the “Your code so far” section not showing your backslashes.

Can you change your post to show “(backslash)” where you have them in your code? Hopefully we’ll be able to get a better understanding of where you’re at

your solution is …below:
var myStr =“I am a “double quoted” string inside “double quotes”.”; // Change this line

I am here and I believe I have answered it correctly but still I get an erro. I maybe need to have a way of escaping this part and move on since it is not the only stuff I need to learn in javascript. Here is the answer I provided:

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

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

1 Like

you have correctly escaped only one of the quotes, if you leave a space between the backslash and the quote you are not escaping the quote

anyway, you can do the lessons in any order, just go to “Curriculum” in the menu, and from there to any lesson you want to do

Thank you. I am new here and so I appreciate your help and kindness. I am just a little frustrated because I have followed what you have suggested and I do not know why I do not seem to get it right. Here is the screenshot:

now your sentence results as I am a"double quoted"string inside"double quotes"., you are missing some spaces

you really just need to write the sentence as instructed, and then move the cursor just before the quotes you need to escape and add a backslash there

1 Like

I guess I will go back to the question, read carefully and give it another try. Thanks a lot.