Basic JavaScript - Escape Sequences in Strings

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

const myStr = "FirstLine\n\\SecondLine\\\n\rThirdLine\n\t"; // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Escape Sequences in Strings

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!


What’s going on here?

Meu codigo = const myStr = “FirstLine\n\SecondLine\\n\rThirdLine\n\t”;

Eu estou tentando realizar o exercício, porem esta dando o mesmo erro não importa quantas vezes eu reveja.

Pode ser um bug?

Erro = // running tests There should be a newline character between

SecondLine

and

ThirdLine
myStr

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

Yes, you wrote a bug in your solution.

The result must exactly match this, with zero extra or moved parts.

FirstLine
    \SecondLine
ThirdLine

So

  1. The phrase “FirstLine” on one line
  2. A tab, a backslash, and the phrase “SecondLine” on the next line
  3. The phrase “ThirdLine” on the next line

Don’t add anything other than that!

Fiz exatamente isso, mas o exercício dá erro, não consigo ir para o próximo exercício!

The last code you posted did not do that. If you have new code, please post it.

const myStr = "FirstLine\n\\SecondLine\\\n\rThirdLine\n\t";

esse código está com 5 dos 7 critérios corretos, se deixar exatamente como você recomendou eu consigo apenas 4 de 7

  • where is the tab on the second line?

  • why is there an extra backslash at the end of the second line?

  • why is there a newline and a carriage return after the second line?

  • why is there a newline and tab after the third line?

The tests will only pass if you have exactly these things and nothing else:

const myStr = “FirstLine \n \SecondLine\ \rThirsLine”; // Change this line

// running tests

myStr

should not contain any spaces

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

  • You added an extra space after the phrase “FirstLine”

  • You added an extra space at the start of the second line

  • You are missing the tab character before the phrase “SecondLine”

  • You removed the escape character before the backslash on the second line

  • You still have an extra backslash (unescaped) at the end of the second line

  • You mispelled “Third”

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