Need help in "Escape Sequences in Strings"

Need help in "Escape Sequences in Strings"


Hey, I want to get help on this chapter,
I tried lots of other ways but nothing works, I need help escaping the sequences…

Here’s my code
var myStr = "FirstLine'\n'\\\\SecondLine\\\\'\n'ThirdLine"; // Change this line



You don’t need single quotes around \n


Here are some rules for using escape sequences that may help you out in the future:

  • If the string iis surrounded in double quotes, you don’t need to escape single quotes.

  • If the string is surrounded in single quotes you don’t need to escape double quotes.

  • Escape sequences can be used for other characters as well such as tabs (\t);

When using escape sequences I like to think of the backslash as a ladder that the next character can use to climb out of the string.,

Hope this helps.


I might be late to this but here is the answer:
var myStr= “FirstLine\n\SecondLine\\rThirdLine”;