Challenge Waypoint: Escape Sequences in Strings has an issue.
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
var myStr = "\\ \t \t \r \n"; // Change this line
The point is:
1) if I use the same line for assignment and declaration, i.e. result looks like:
var myStr = "\\ \t \t \r \n"; // Change this line
, then mini console log (under reset/help/bug buttons) returns: undefined (which is probably a bug)
2) because if I use another line to assign the variable, so that result looks like:
var myStr; // Change this line
myStr = "\\ \t \t \r \n";
, then mini console returns: \ (which is probably correct)
This does not prevent a user from passing the challenge on Ctrl+Enter, so this issue's probably not substantial.
This is due to the fact that by default we're taking the return value of whatever the last line of code is and an interesting aspect of javascript is that variable assignments have return values but variable declarations do not. However, we can get around this by adding a display function in the tail section of the challenge json that will always display the myStr
variable.
@ltegman Is the solution correct?
The solution that is accepted is var myStr="\\ \t \t \r \n";
.
I feel the encoded myStr
should be var myStr="\\ \\t \\t \\r \\n";
This encodes these characters and print them on screen as \ \t \t \r \n
.
I was just missing out on the spaces, you gotta give only single space. else it won't work
removed solution by mod
@fdolzaneits1 it's true but what about implementing the text inside the myStr?
There is a space in myStr.
Whomever will look at this topic, Please use
alert(myStr);
in line 3, You will see that the second backslash may not seem as you expect.
this code isn't working for me atall
var myStr="\ \t \t \r \n"; // Change this line
what should i do friend am completely stuck!
Hello my friend ? can you try with this one line below ?
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
Thank you ...
On Tue, Dec 27, 2016 at 9:06 AM, francis Murungi notifications@github.com
wrote:
this code isn't working for me atall
var myStr="\ \t \t \r \n"; // Change this line
what should i do friend am completely stuck!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/5673#issuecomment-269353103,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVHNK0cIL5puqxSSbKN4CJTc_mWUyTlXks5rMUV5gaJpZM4G9WAE
.
@francis951 @kellykevin
Please use the HelpJavaScript chat room for getting challenge related help.
Happy Coding.
Most helpful comment
removed solution by mod