Escape Sequences in Strings challenge update?

Most of the solutions I’m seeing are a few years old and It isn’t solving my problems
here’s the string I’m having some issues with

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.

Note: The indentation for SecondLine is achieved with the tab escape character, not spaces.

here’s what I typed:

var myStr = “FirstLine\n\t\SecondLine\nThirdLine” ;

any thoughts on how to get this challenge solved??

Can you post a link to the challenge?

By the way welcome to freecodecamp forum!

Sure!

Thank you for your warm welcome

Do you get an error with your code? Or what does the output terminal say?

yes,

// running tests

myStr

should contain the strings

FirstLine

,

SecondLine

and

ThirdLine

(remember case sensitivity)

FirstLine

should be followed by the newline character

\n
myStr

should contain a tab character

\t

which follows a newline character

SecondLine

should be preceded by the backslash character

\

There should be a newline character between

SecondLine

and

ThirdLine
myStr

should only contain characters shown in the instructions // tests completed

Recheck what you are missing. You are missing just one thing in your code.

“FirstLine\n\t\SecondLine\nThirdLine”;

I added new line character
backslash character preceeds SecondLine (but it’s showing as that one this thread)
newline and tab character also included.

what could I be missing.hmmmm?

Check again. Hint: you are missing one symbol. :grinning:

Screenshot 2021-07-06 at 09.41.58

is symbol still missing?

you got it. Did you pass the test?

Unfortunately, I’m still getting the error.

Try using this quote " " Instead of what you have.

"Use this quote"

“Instead of this” 

it’s double quoted already

The quote that you are using showed an error in my console too but I changed it to the quote above and it worked.

Try using this one to see if you pass the test.

" " does not work as well

1 Like

I am not really sure in that case. This code actually passed the test for me.
Try copying this and if it doesn’t work then let’s wait for the input of someone more experienced. I am tagging @JeremyLT

var myStr = "FirstLine\n\t\\SecondLine\nThirdLine" ;

What does it show in your console? Can you post a picture like this?

image

This works fine . The problem was there was a semi colon -which is meant to be at the end- between var myStr and assignment operator =

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.