I'm stuck can't move further, please i need help:Escape Sequences in Strings

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.

“FirstLinenewlinetabbackslashSecondLinenewlineThirdLine”

Here is what i code :

var myStr="FirstLine\n\SecondLine\\rThirdLine";//Change this line

don’t know where am getting it wrong.

You need to escape the \ character.

Thanks i got the code write now

Thanks i got the code right now.

can you please share your new code to help others understand better? Thanks :slight_smile:

@shoushou

below is my new code. i hope it will be of help to someone else? Thanks.

var myStr= "FirstLine\n\t\SecondLine\nThirdLine"; // Change this line


1 Like

1.\n [ it will create newline]
2.\t [ it will create tab(space) and newline]
var myStr = “FirstLine\n\t\SecondLine\nThirdLine”;