Quoting Strings with Single Quotes! PROBLEM WITH BACKLASHES

I removed all the backlashes and it still says that there are some backlashes to be removed… i cannot find them

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/75.0.3770.142 Safari/537.36.

Link to the challenge:

You added a > where it doesn’t belong.

it still says the same thing…

What is your current code?

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

I’ve edited your post for readability. 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 easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


Now it looks like you’re missing a single quote and a forward slash.

1 Like

MUCH better topic name, @marlawashere.

So you’ve got the backslashes handled, kudos. But the thing biting you now is a common problem - when you open a quote, whether single quote ( ' ) or double quote ( " ), it has to have a match. You can’t open a quote and not close it. Javascript refers to that as an unterminated String, and it causes javascript some confusion.

See how, right after the var myStr =, you have that single quote mark? Where’s its buddy? :wink:

The point of this lesson is, within a single-quote string, you can embed double quotes without needing to do some special escape trick. Or, within a double-quoted string, you can use single quotes as though they’re just a normal character. But if you surround a string with single quotes and try to embed that single quote, you have to ‘escape’ it with the backslash.

For example, 'This isn\'t a number, it\'s a string' - in order to use the apostrophe in there, I had to either use the backslash, OR replace the surrounding quotes with double quotes: `“This isn’t a number, it’s a string” is fine.

1 Like

okay i see what you mean. thank you soooo much… i also got a question what is escaping?

You escape a character so that the code see the character not as a special character

There are some characters that have special significance in a programming language. For example, within a string surrounded by quotation marks ( "..."), I couldn’t have a quotation mark without some fancy footwork: "The story goes, \"Once upon a time...\" ... and on and on" <-- in that string, the quote marks WITHIN the quote have been ‘escaped’ by leading with a backslash. I’ve told javascript’s String interpreter, “The next character is a part of the string, and not the END of the string.”