Escape Sequences in Strings - Help Please

Escape Sequences in Strings - Help Please
0
#1

What am I doing wrong here?

Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine
ThirdLine

You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLine newline tab backslash SecondLine newline ThirdLine


var myStr; "FirstLine\n\t\\SecondLine\nThirdLine";



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.2; rv:63.0) Gecko/20100101 Firefox/63.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/escape-sequences-in-strings

0 Likes

#2

The \SecondLine is tabbed, but doesn’t show on the post.

Thanks

0 Likes

#3

The formatting makes it hard to tell, but are you actually assigning the string to myStr. (forum code formatting)

0 Likes

#4

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.

0 Likes

#5
var myStr; "FirstLine\n\t\\SecondLine\nThirdLine"

See again the Storing Values with the Assignment Operator challenge and the Initializing Variables with the Assignment Operator challenge

0 Likes