Escape Sequences in Strings "NOT WORKING"

Tell us what’s happening:

Your code so far

var myStr = "FirstLine\n\\SecondLine\\\rThridLine"; // Change this line

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; CrOS armv7l 10032.75.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.116 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/escape-sequences-in-strings

:thinking:

I have been to several different links online! I have tried this problem 10 different ways and it does NOT PASS THE CODE. Why are people saying check capitals??? If the solution they post doesn’t work in (l vs L). Or ("" vs ‘’)!

New line = \n right?
Backslash = \\ right?
Carriage-return = \r right?

So what is going wrong here. There are people on all three sites posting the wrong answer/solution. An when people try to explain their reasoning it doesn’t work. The instructions are below. I’m so lost. Someone please in Clear English without playing games…
Tell me what I’m not understanding.
I have checked spelling, CameLCase, and double quotes. And it still doesn’t pass mustard.

Sigh

/*
Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
*/

Check out the following links:



@404HelloWorld,
I don’t see anything wrong with your code.

I wrote the following in the challenge and it worked

“FirstLine\n\SecondLine\\rThirdLine”

What errors are you getting?

1 Like

Hi thanks for responding!!!

This is the error.

myStr should have encoded text with the proper escape sequences and no spacing.

The rest of the objectives are Green!

try pasting the solution I wrote and see if you pass the test.

i stucked with it but finally i tried that and it works
var myStr = “FristLine\n”+"\SecndeLine\" +"\rThirdLine";

“FirstLinenewlinetabbackslashSecondLinenewlineThirdLine”
newline = \n
tab = \t
backslash = \\
“FirstLine\n\t\\SecondLine\nThirdLine”;

1 Like

I did the following and it liked it.
myStr = “FirstLine\n\t\SecondLine\nThirdLine”; // Change this line

Here’s the answer:

<redacted>

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

If you want to compare your solution to others, use the Get a hint button on the challenge and there are alternative solutions you can compare yours to. Also, you can probably search older posts using the forum search feature or google the challenge name and find more there.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

where in the challenge did it ask for a carrige return? and where is your TAB?

Work on the problem one at time, and pay attentiont to the output window. For example:

  1. I applied the ‘newline’ first, then watched as the string starts to line up vertically in the output window:
    FirstLine
    SecondLine
    ThirdLine

  2. Looking back at the requirement, the SecondLine appears indented, so apply ‘tab’
    FirstLine
    ______SecondLine
    ThirdLine

  3. Finally applying backslash to SecondLine. I watched it change in the output window into the final required output.
    FirstLine
    ______\SecondLine
    ThirdLine

  4. Review for case sensitivity check, then submit.