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'
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?
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.
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.