Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New line character is required before third line #10485

Closed
tauheedkhan opened this issue Sep 5, 2016 · 16 comments
Closed

New line character is required before third line #10485

tauheedkhan opened this issue Sep 5, 2016 · 16 comments
Labels
help wanted Open for all. You do not need permission to work on these.

Comments

@tauheedkhan
Copy link

Challenge Escape Sequences in Strings has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

var myStr="FirstLine\n\\SecondLine\\\rThirdLine"; // Change this line

@tauheedkhan tauheedkhan changed the title New line character id required before third line New line character is required before third line Sep 5, 2016
@dhcodes dhcodes added the status: blocked Is waiting on followup from either the Opening Poster of the issue or PR, or a maintainer. label Sep 6, 2016
@dhcodes
Copy link
Contributor

dhcodes commented Sep 6, 2016

@tauheedkhan Could you provide some more information? If you're curious about why there isn't a new line before the third line, it's because it uses a carriage return which is quite similar. You can read about the differences here: http://stackoverflow.com/questions/1761051/difference-between-n-and-r

@erictleung
Copy link
Member

@dhcodes I think the issue comes from the instructions

Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine

Because when you print out the correct string, you don't get that new line.

image

We can either add the \n requirement on top of the carriage return or we can replace the carriage return for the \n requirement.

Although I liked having carriage return in the challenge so that you're able to try different escape characters, practically, we'd probably want to use \n as it'll more commonly be used. So I'd go for replacing the carriage return with a new-line, but I'm open to either.

@erictleung erictleung added status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. and removed status: blocked Is waiting on followup from either the Opening Poster of the issue or PR, or a maintainer. labels Sep 6, 2016
@tauheedkhan
Copy link
Author

@erictleung In either case, expected result should be changed as carriage return will not give you a new line. Although I agree, using as many escape sequence in the problems is good for better understanding.

@BKinahan
Copy link
Contributor

BKinahan commented Sep 6, 2016

Ah, when I wrote this string for the challenge I tested it in repl.it and the FCC console, but not in browser consoles. In the former \r does introduce a line break but not in the latter.

I'd suggest replacing the \r requirement with a second \n, but also changing one of the escaped backslashes to a different character to maintain the diversity of escaped characters used. Perhaps this: "FirstLine\n\t\\SecondLine\nThirdLine"

FirstLine
    \SecondLine
ThirdLine

It loses some symmetry but should resolve the issue 😄

@erictleung
Copy link
Member

erictleung commented Sep 8, 2016

@BKinahan sounds like a good compromise to me! 👍

@erictleung erictleung added help wanted Open for all. You do not need permission to work on these. and removed status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. labels Sep 8, 2016
@ktajpuri
Copy link
Contributor

ktajpuri commented Sep 26, 2016

@erictleung @Bouncey Can I work on fixing this one?

@dhcodes
Copy link
Contributor

dhcodes commented Sep 26, 2016

@ktajpuri 👍 go for it :). If you have any problems, you can ask for help in the Contributors chat room

@systimotic
Copy link
Member

@ktajpuri Are you still working on this?

@elisecode247
Copy link
Contributor

I'd like to work on it if it's open

elisecode247 added a commit to elisecode247/FreeCodeCamp that referenced this issue Oct 14, 2016
The return carriage didn't give a new line, so the string is re-written. The Spanish translation is also updated. From issue 'new line character is required before third line'  freeCodeCamp#10485.
rarmatei pushed a commit to rarmatei/freeCodeCamp that referenced this issue Sep 3, 2017
The return carriage didn't give a new line, so the string is re-written. The Spanish translation is also updated. From issue 'new line character is required before third line'  freeCodeCamp#10485.
mhatout pushed a commit to mhatout/freeCodeCamp that referenced this issue Feb 9, 2018
The return carriage didn't give a new line, so the string is re-written. The Spanish translation is also updated. From issue 'new line character is required before third line'  freeCodeCamp#10485.
@Waseemarif
Copy link

It's not working
var myStr = "FirstLine\n\SecondLine\n\t\rThirdLine";
same Error: There should be a newline character between SecondLine and ThirdLine

@StepanBohdan
Copy link

StepanBohdan commented Jul 24, 2018

RESOLVE
var myStr = 'FirstLine\n\t\SecondLine\nThirdLine';
var myStr = 'FirstLine\newline\tab\backslashSecondLine\newlineThirdLine'

@dogomeodenzoy
Copy link

Try this one: works for me,

image

@Domitech27
Copy link

var myStr = "FirstLine\n\t\SecondLine\nThirdLine";
This is what solve this challenge
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/escape-sequences-in-strings/

@mtarun15
Copy link

var myStr = "\nFirstLine\n\t\SecondLine\nThirdLine";
This gave me the solution.

@DevAashish08
Copy link

"\nFirstLine\n\t\SecondLine\nThirdLine";
not working

@RandellDawson
Copy link
Member

I am locking this because this issue has been closed and the other comments I am seeing should be addressed on the forum.

@freeCodeCamp freeCodeCamp locked as resolved and limited conversation to collaborators Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Open for all. You do not need permission to work on these.
Projects
None yet
Development

No branches or pull requests