Javascript quotes within a strings

Hello ,
Fellow coders.
Anyone to kindly help me with a solution for double quoted marks within a string i have tried to use escape backslash but it is escaping the last quotation mark.

var myStr= "I a m \"double quoted\"  string inside a \"double quotes\". ";

you can use a different pair of quote marks from the ones which contain the string. For example use " " to contain the string and withing it ' ' for quotation. The other way around also works. Example solution- 'this is a string "and this is quotation within the string" end of string'

Hi!

Typos:

  1. I am a is right (you have I a m)
  2. There is only one space before string and you have two.
  3. There is no space for the last " and you have one.

The test requires me to use for escape backslash and double quotes.

sorry, i didnt realize the conditions

Lol. no need to apologize I am here to learn you used your precious time to help for that I am very thankful.

2 Likes

I tried the exact code in the console and everything is escaped correctly. The quotes inside are red (text) whereas the outside ones are identifying it as string.

Where is the problem? Can you add a screenshot of the output?

as seen on the picture it has escape the closing double quotes. leaving “.;” instead of .";

you have extra characters

I a m instead of I am, for example

it’s not only escaping the quotes, you need to use the exact string the tests ask you to use

Captur

That is the question

There shouldn’t be an a there and the semicolon should be outside the quotes.

I have tried but it is still giving me an error

You still have a spacing issue though.
Right now it reads inside"double

It should read inside "double.

And it read am a"double.
It should be a "double.

And quoted"string
should be quoted" string.

And the semicolon should be outside the string.

Spacing is really important to solve this challenge.

I would look at the original sentence and make sure yours looks exactly like the original.

Hope that makes sense.

1 Like

Here’s the comparison of what your string is and what it should be

// Your string
"I a m \"double quoted\"  string inside a \"double quotes\". ";
//What it should be
"I am a \"double quoted\" string inside \"double quotes\"."; 

spacing does matter so space it properly. Also “a” in the string which should be there. Be sure to cater these intricacies while solving the fcc coding challenges.

Actually I should have mentioned this earlier but you should avoid posting screenshots for code but rather post your code directly in the forum.

It will cut down on confusion because @Freak_A_tick is commenting on your original code whereas I am commented on the updated version of your code from the last screenshot.

But we are still saying the same thing which is you have a spacing issue and the sentence itself is not correct.

For future posts, please write your code directly into the forum. Thanks!

Instructions for writing code into the forum

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 it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

var myStr = "I am a \"double quoted\"string inside \"double quotes\".";
I have tried to space properly it is still brings the same error and escaping the closing quotation marks too.

When I run the test it prints this.
myStr = "I am a “double quoted"string inside “double quotes”.”

You need to add one space for the test to pass.

Here is the original again
I am a “double quoted” string inside “double quotes”.

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