Quoting Strings with Single Quotes please help

Quoting Strings with Single Quotes please help
0.0 0

#1

Tell us what’s happening:

Your code so far


var myStr = "<a href='"http://www.example.com'" 'target'='"_blank'">Link</a>"';


Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/quoting-strings-with-single-quotes/


#2

Hey, you’re overthinking it a bit. In this challenge, the original string uses double-quotes everywhere. Because of that, every double quote inside the string has to be escaped.

var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>"

Since typing backslashes sucks, it’s nice to enclose the entire string in single quotes and then the double quotes don’t need to be escaped anymore. So basically, solving this challenge requires two steps:

  1. Change only the outermost double quotes to single quotes
  2. Remove all the escaped characters inside the string.

This is just what it says in the instructions:

Change the provided string to a string with single quotes at the beginning and end and no escape characters.

The problem with your attempt right now is that you’re putting single quotes throughout the string, rather than just using them at the beginning and end.

Hope this helps. Reply if you have questions. Good luck!


#3

i can’t solve this …please give source code…


#4

Sorry, man. I’m not going to just give you the answer, but I’d be happy to walk you through it step-by-step.

For a first step, just replace the double quotes on the very outside with single quotes. For example, if the original string were this:

var myString = "\"Quotation marks are annoying,\" said Sabbir-Ahmed";

you’d just change the first and last " into 'so that the string would now look like this:

var myString = '\"Quotation marks are annoying,\" said Sabbir-Ahmed';

Try doing that on the original string in the challenge, and then post your result. If that looks good, I’ll walk you through the next step. Good luck.