Help Please! Escape sequences

Hope someone can help me out with the javascript escape sequences challenge.
I have tried at least a dozen different combinations and can’t seem to get it right. This is really twisting my mind.
As I see it the challenge string looks like this before being escaped.
**"FirstLine\n\SecondLine\\rThirdLine"**
This is what I thought would be the solution for the escaped string.
**\"FirstLine\\n\\SecondLine\\\\rThirdLine\"**
Having trouble grasping this.

Look carefully at what the challenge asks you to output.

FirstLine
\SecondLine\
ThirdLine

Hint #1 - What you need is something that breaks after the “FirstLine” text, but then leaves a slash in together with the “SecondLine” text.

Hint #2 - The challenge is not asking you to display the quotation marks in the output. You don’t need to break out of the quotation marks.

(PS. I don’t mean to be cryptic about this. But I don’t want to solve the challenge for you. I’m happy to give more hints if you feel you need them, just ask!)

1 Like

Just to add on to what garroadran is saying, yes, a bit problem is the quotes you are escaping. I think you are confused. Don’t confuse the quotes that surround a string with the quotes that are in a string. For example:

var str = "I said I love you.";
console.log(str) // outputs => I said I love you.

but…

var str = "I said, \"I love you.\"";
console.log(str) // outputs => I said, "I love you."

Do you see the difference? You will always need a quote at the beginning and the end - those are never escaped - but if you want a quote of the same type inside the quote (actually appearing when outputted) it must be escaped. The string they’ve given you to duplicated does not have outputted quotes so no quotes need to be escaped. You just need the usual beginning and end quotes that you would in any strings.

And look at your escapes for n and r. You only need one backslash. If you put two, it assumes that that is the escape sequence for a backslash and then a regular n or r. You only do the double backslash if you are trying to do an escape sequence for a backslash, to output a backslash to the screen. We need two of those for this string, but it is different from the escape for n and r.

garradran & ksjazzguitar thank you both for taking time to help me out.

Turns out, that I had the correct solution the very first time I tired, with one small mistake. I had a space between the = symbol and the " double quotes that procede Firstline. Really made me try to overcomplicate things.

Funny how something that simple can really twist a guy up.