# Escaping Literal Quotes in Strings

**URL:** <https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748>\
**Category:** JavaScript Bootcamp\
**Created:** [January 12, 2022, 8:37am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748 "2022-01-12T08:37:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![talenttinaapi2675228](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@talenttinaapi2675228](https://group.classcentral.com/u/talenttinaapi2675228)\
**Post date:** [January 12, 2022, 8:37am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748/1 "2022-01-12T08:37:01Z")

</div>

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:

```auto
I am a "double quoted" string inside "double quotes".

```

---

<div class="post-metadata">

**Author:** ![hola\_soy\_milk](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/hola_soy_milk/32/600_2.png) [@hola\_soy\_milk](https://group.classcentral.com/u/hola_soy_milk)\
**Post date:** [January 12, 2022, 8:46am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748/2 "2022-01-12T08:46:28Z")

</div>

Hello!

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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_sequences) on this.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Fabio](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/fabio/32/177_2.png) [@Fabio](https://group.classcentral.com/u/Fabio)\
**Post date:** [January 12, 2022, 11:56am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748/3 "2022-01-12T11:56:25Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ccstudygroup/original/2X/8/8fb847811a2fa5e75196d16bb527ad80b225d106.png)

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

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ccstudygroup/original/2X/5/5ea57566879b91658271591ba8974651fbcf99e5.png)

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!

---

<div class="post-metadata">

**Author:** ![lindsayward](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/lindsayward/32/3667_2.png) [@lindsayward](https://group.classcentral.com/u/lindsayward)\
**Post date:** [January 13, 2022, 2:38am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748/4 "2022-01-13T02:38:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![monicajasper](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/monicajasper/32/1477_2.png) [@monicajasper](https://group.classcentral.com/u/monicajasper)\
**Post date:** [January 15, 2022, 1:13am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748/5 "2022-01-15T01:13:43Z")

</div>

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='http://www.example.com' 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!

---

<div class="post-metadata">

**Author:** ![richardmarks2704229](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@richardmarks2704229](https://group.classcentral.com/u/richardmarks2704229)\
**Post date:** [January 15, 2022, 7:54am UTC](https://group.classcentral.com/t/escaping-literal-quotes-in-strings/21748/6 "2022-01-15T07:54:56Z")

</div>

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/
