Escape Sequences in Strings(help plzz)

Tell us what’s happening:

Your code so far


var myStr; // Change this line

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/escape-sequences-in-strings

What is it that you are not understanding? Please tell us the problem that you are facing specifically.

I am assuming you don’t know how to proceed with it?

Strings start with single quotes ' and double quotes ". Anything inside these will be a string. Those quotes will not be included. Now what if you want to include them as well? We need to ‘escape’ it, that is, we need to tell Javascript that when we enter a ‘specific’ sequence of characters, then you should do something ‘specific’ with it.

For eg, in HTML, when you write just ‘div’, it will print ‘div’, but if you write it in a specific manner, between < and >, the HTML identifies it as a tag, and it will treat it as a tag and won’t print it.
This is not escaping, it’s just a way to write a tag, but if you get this, you will understanding what escaping a character means.

Back to including single and double quotes in JS. So you escape the single quote by writing backslash ‘’ first and then the quote, like this: \'. So when you console.log(' \' '), you will see '. Because JS will see this specific pattern and understand that anything after \ has to be (escaped) included in the output.

You cannot directly output the \ backslash character. But now you know what you have to do.
console.log(' \\ ')

Refer to the side bar in the problem to see what all you can escape.

You have to do this
FirstLine
(this is on a new line, so you have to insert the ‘new line’ escape sequence here, which is given in the side bar)(We also have a backslash ahead, so you know what to do in order to be included in the text)\SecondLine
ThirdLine

Note that everything has to be in a single line in the console.log or when declaring it to a variable, like myStr.

All the best!