Escaping Literal Quotes in Strings ugh too annoyed now. pls help

Tell us what’s happening:

ive looked over this site more than i care to on this problem. if anyone got the solution lmk. write it out and explain what the problem is. and why its wrotten that way? it just dont make sense what so ever. ive tried and tried and wanting to throw my laptop now.

Your code so far


var 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; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0.

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

Hello! Don’t throw your laptop yet.

Look at this example, this would help you:

var myStr = "I am a string";
// saves "I am a string" in the variable myStr.

You can notice that what is being saved in the variable is inside quotes, so, if you do something like this

var myStr = "I am the "nice guy""
// Throws an error, because the quotes
// marks the beginning and the end of the word that you are going to save..

In that order, it is storing "I am the ", and then, it’s given more information that throws to an error (nice guy""). What we need to do is to tell that those quotes are not for finishing the string. That is achieved by using \ like this \"

Then, if you do:

var myStr = "I am the \"nice guy\"";
// it will store: I am the "nice guy"

And that would work :slight_smile: I hope my example helps you

4 Likes

var myStr = "I am a \"double quoted\" string inside \"double quotes\"."; // Change this line
found a video online doing the same subject lol. and finally after the guy explained where things go i got it and there it is. and tysm @Kurtony for the explanation as well. i was pretty serious on that throwing part. trust me. lol.

your issue is that you don’t have quotes surrounding the string… when you have a string you always need a quote at the beginning, and one of the same kind at the end - those aren’t present in your code