Could some one please help

Could some one please help
0

#1

For some reason, my code will;l not run and I do not know why for lesson 56 javascript var myStr = “I am a"double quoted"string inside"double quotes”."; this is the code I wrote and this is the example
could some one, please help.


#2

Can you copy/paste the code into a reply, so we can see all your code?

When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a 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.


#3

Hopefully this improves the conversation.
I’ve yet to get to that problem but my guess is double quotes in other double quotes should be single quotes.

Example:

“I am a ‘string inside’ this code”.

Or: single quotes on the outside, and double on the inside; they can replace one another.

Might be a wrong, it has been a while.


#4

Here is my code

var myStr = “I am a"double quoted"string inside"double quotes”.";
i have tried to not use the backslash and just use double quotes but it still would not run


#5

If the title of the challenge is "Escaping Literal Quotes in Strings ", then you must use the backslash to pass this challenge. Can you show what you tried when you did use the backslash? Then I can explain why it did not pass when you tried it.


#6

Works in a few circumstances, but not a general solution. What if your string contains both single and double quotes? What if your organization’s coding style guide and editorial style guide both require the same type of quotation marks?

Instead, you need to escape the quotes in the string. Escaping is simple: just put a backslash before the character.

"\"" // literal double quote
'\'' // literal single quote
'\\' // literal backslash
var vultan1 = "\"Gordon's alive!\" - Prince Vultan";
var vultan2 = '"Gordon\'s alive!" - Prince Vultan';
vultan1 === vultan2; // true

#7

Good response, makes sense. Cool. I’ve learnt something. Thanks.