var myStr="\"FirstLine\"\n\\\"SecondLine\"\\\r\"ThirdLine\"";
First thing I can see is the end of it. You can’t have two " next to each other.
One possible solution is to make the first and last quotr single quotes. This gets you a little bit closer.
I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.
What errors are you getting with this line?
i take it your trying to have 3 quoted lines of text … one on each line … this i how i changed yours
var myStr='\"FirstLine\"\n\"SecondLine\"\r\"ThirdLine\"';
“FirstLine”
“SecondLine”
“ThirdLine”
All of the quotes are escaped, so the string is valid with single or double quotes. The \r
may be what is causing unexpected behavior - that is, a lack of behavior as it won’t make a new line.
But this is speculation until we know what the issue actually is.
noticed that about the r … gives a new line in repl.it and phytontutor … but not if you do it in the console.
im persuming the issue is the second line of his code is printing … “SecondLine”\ and he dosent want the \ showing
tis was the error
myStr should have encoded text with the proper escape sequences and no spacing.
those are supposed to show
var myStr='\"FirstLine\"\n\\\"SecondLine\"\\\r\"ThirdLine\"'; // Change this line
this still not working.
Why are you being inconsistent with the usage of your carrier return?
You’ve got \n
in one instance and \r
in the other. You’re trying to achieve the same thing twice, which is to break twice.
This works: var myStr = '\"FirstLine\"\n\"SecondLine\"\n\"ThirdLine\"';
if you’re trying to achieve:
“First Line”
“Second Line”
“Third Line”
Is that the case?
Hi the challenge demands one \n and one carrier return
Which challenge? Link?
SPOILER!!!
Ok I see. I found it.
This was my solution
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
Thanks man that works