Search code examples
javascriptescaping

what is wrong with my code in this "Escape Sequences in Strings" challenge on FreeCodeCamp?


I can't seem to get past this challenge and it's driving me nuts. I thought I followed the instructions correctly. Can someone please figure out what the error is? (I have a feeling it's something stupidly simple.)

The challenge is here: https://www.freecodecamp.com/challenges/escape-sequences-in-strings, below is my code.

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

Thanks in advance!

Edit: 1st line error: unexpected '\' and missing semicolon; 2nd line error: unexpected '\'; 3rd line error: unexpected '\'


Solution

  • In order to make the challenge work, you're going to need your whole string in quotes and on one line.

    So change

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

    to

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