Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Javascript CodeChallenge Escape Characters

This code challenge is very confusing.

I passed the first task, and then by the second task it says "It looks like Task 1 is no longer passing" when I try to check the work.

Task 2: Set the 'escapedBackslash' variable to the string of a backslash character.

Here is what I'm putting:

var escapedNewLine = "\n"; var escapedBackslash = "\";

Where am I going wrong? I didn't see this issue in any of the questions already asked. Thank you

2 Answers

If you can understand that a backslash character ( \ ) is what tells the computer to 'escape' or 'don't register as a string' the NEXT character after it, then you might be able to take a good guess at how to solve this challenge.

For example, if the \n tells the parser, "I put a backslash in front of this character (n) so you know that this next character must do something special, besides printing an 'n'!."

In the second question, you've correctly told the parser to do something special by putting the backslash in, but what other information is it looking for after the backslash?

Take a look at 1:50 of the previous video (Escape Characters) to see a good example of how he solves this problem.

Ahh yes I see now. Thank you!