Escape Sequences in Strings

This what is required
Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Run tests (ctrl + enter)
Reset Help Bug

SyntaxError: Invalid or unexpected token

myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
below is my change to the original code
var myStr = FirstLine\n /SecondLine/r ThirdLine\;

var myStr=Firstline\Seconfline\rThirdLine\;
This my new answer but its wrong
See below what they want me to do
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \

Yes it is annoying , coding really deserving attention in small detail

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

this is the correct answer, there will be 2 backslashes before and will be 3 backslashes after SecondLine

The right answer should be :
var myStr=“FirstLine\n\\SecondLine\\\rThirdLine”;

The backslash should be \\ instead of \

I guess ferhotguy got it right, but there’s issue with code editor here

cheers

4 Likes

WOW … seriously, what the heck is that about? :scream:

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

Eventually I got it to except my answer. But what it really means is another thing!

it is not working the first condition is not yet becoming successful

Can you post your code here?

was able to pass the challenge using this:

var myStr="FirstLine\n\\SecondLine\\\rThirdLine";

1 Like

I used your code but the output doesn’t match what it says the output should be. I can’t help but feel like something is wrong.

yep bro, this is the right ans.

the mistake is the “;” in the initial code instead of = sign

var myStr; // Change this line

the correct answer is :slight_smile:


var myStr= "FirstLine\n\\SecondLine\\\rThirdLine";

Side note, if some of you use Repl.it, carriage return and newline don’t work as expected. Otherwise it’s a pretty great tool.

var myStr = “FirstLine\n\\SecondLine\\rThirdLine”;
note: see for capital letter when typing.