Escape Sequences in Strings

Escape Sequences in Strings
0

#1

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\;


Escape Sequence Javascript
#3

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 \


#4

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


#5

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


#7

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!


#8

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


#9

Can you post your code here?


#10

was able to pass the challenge using this:

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


#11

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.


#12

yep bro, this is the right ans.


#14

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";


#15

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.


#16

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