Help! Escape Sequences in Strings

Please help. I’ve done all the challenges in Basic Javascript except for the “Escape Sequences in Strings” one. It seems like it should be simple, but I just can’t get it. Here’s the instructions:

Instructions
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.

“FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine”

My attempts:

var myStr = “FirstLine\nSecondLine\rThirdLine”;
var myStr = “FirstLine\n\SecondLine\rThirdLine”;
var myStr = “FirstLine\\nSecondLine\rThirdLine”;

None of these work :confused:

I figured it out -_-

you could explain how you did it for others struggling with the same/similar problem :slight_smile:

1 Like

Try this one.
var myStr = “FirstLine\n\tSecondLine\nThirdLine”;

2 Likes