Escape Sequence in String

Tell us what’s happening:

It’s probably a simple question, but I am really confused on how to go about this.
It is asking:

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

FirstLine
\SecondLine
ThirdLine

my code so far:

var myStr; //\nFirstLine\t\nSecondLine\\\nThirdLine



Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.

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

First you need to assign a string to myStr. You currently have not done that. Also, where ever you want to display an actual \, you will need to escape it.

1 Like

It looks like the code that you have in the comment (after the //) is on the right track, but the elements need to be in a slightly different order. (EG your escaped slash, //, is currently at the end of the second line instead of where it should be.)

Once you get that section written as a string and assigned to a variable, you will be able to see it in the test output box.

1 Like