what is wrong with my code in this "Escape Sequences in Strings" challenge on FreeCodeCamp?
11,496
Solution 1
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";
Solution 2
valid 2021,2022, 202x URL link to the problem:
freeCodeCamp asks for it as console output;
FirstLine
\SecondLine
ThirdLine
this is the solution to the problem;
var myStr = "FirstLine\n\t\\SecondLine\nThirdLine";
- With "\n" we move to the new line.
- With "\t" we create a space on the new line.
- With "\" we write the \ character on line 2.
sorry for my bad english.
Author by
Bethany Hible
Updated on June 05, 2022Comments
-
Bethany Hible almost 2 years
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 '\'