Tried many ways, and looked for many examples. For the returns, how should they be written? I couldn’t find examples to save my life, and when tried on my own the closest I came was 3 out of 4…
var myStr= "FirstLine\n\\SecondLine\\r\ThirdLine";
Tried many ways, and looked for many examples. For the returns, how should they be written? I couldn’t find examples to save my life, and when tried on my own the closest I came was 3 out of 4…
var myStr= "FirstLine\n\\SecondLine\\r\ThirdLine";
Does one of these help?:
Common escaped characters :
’ single quote
" double quote
\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
I don’t understand what is wrong with my carriage return, or my double backslash. I tried all 3 resources, and then took to Google before posting.
Maybe you swapped the order of the r
and the last \
?
You should start billing me, Kev! I’m still getting one error, though…
myStr should have encoded text with the proper escape sequences and no spacing.
Close! Now you have swapped the order of \r
and \\
lol, when my brother asks for help and stuff I often say “At this point I should start billing you.”
your code is…given below…
var myStr= “FirstLine\n\tSecondLine\n\ThirdLine”; // Change this line
So I am kinda confused here. The code listed in the curriculum is as follows:
var myStr ="FirstLine\n\t\\SecondLine\nThirdLine";
However this seems to only work in the FCC environment. I do it in let’s say VS Code or Codepen.io it will not accept the escape characters. They still appear in the code however, they do not actually execute. Why? Has this been deprecated? I have found no evidence of this nor any evidence to support why it only works in your environment. Please help, thank you.
PS. Here is a look at the code in Codepen.io
So method of output is important to know then. Browsers do not display escape characters like they do in the console for some reason (which I must now research and know). I had no idea this was a thing. Thanks.