Escape Sequences

Tell us what’s happening:

i can’t understand what’s going on. I don’t even know what escapse sequence is ?

Your code so far

var myStr=newline tab backslash; // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

Hey Md Rahmatuzzaman,
There are few characters in javascript which are reserved and need to be escaped in order to be used in your string. So, the backslash \ followed by a character is used to escape them.
To escape double quotes you do " and to escape backslash you do \.
in this challenge you have to use newline escape character.
Read the instructions in challenge carefully and it will help you.
Hope it helps.

1 Like

It make sense but it will be more helpful for me if you give me a small example with explanation.

In javascript, you always put string variables in quotes which can be either single quotes '' or double quotes " ".
What if you need quotes in your string. How do you do that?
You do that with escape character. and in javascript backlash is escape character.
For example, i have a string which is Tom says, “I like playing Football.”
If i declare it like var str = "Tom says, "I like playing Football."".
Then, javascript will consider the end of string when i apply the double quotes for 2nd time and not at the end.
So, to avoid javascript from understanding our code in that manner we use escape character.
So, above variable could be properly declared as :
var str = "Tom says, \"I like playing Football\"."
Hope this helps.

1 Like