Creating new line

not sure what I am doing here it was it says to do
const myStr = "FirstLine\n\t\SecondLine\\nThirdLine"; // Change this line

  • myStr` should not contain any spaces

  • Passed:myStr should contain the strings FirstLine, SecondLine and ThirdLine (remember case sensitivity)

  • Passed:FirstLine should be followed by the newline character \n

  • Passed:myStr should contain a tab character \t which follows a newline character

  • Failed:SecondLine should be preceded by the backslash character \

  • Failed:There should be a newline character between SecondLine and ThirdLine

  • Failed:myStr should only contain characters shown in the instructions

You have two backslashes ( \). When you use two sequential escape characters, the first one escapes the second one. What does that mean? "\n" adds the newline character to a string whereas "\\n" adds the characters ā€œ\nā€ to the string.

1 Like

const myStr = "FirstLine\n\t\SecondLine\nThirdLine"; // Change this line
so I took the one backslash out so I dont have two. and it gives me this
// running tests
SecondLine should be preceded by the backslash character
myStr should only contain characters shown in the instructions
// tests completed

thank you I got it i need two backslashes one befor the secondLine and after the \t

1 Like

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