# Escape Sequences in Strings "NOT WORKING"

**URL:** <https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [January 7, 2018, 6:55pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350 "2018-01-07T18:55:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![404HelloWorld](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/404helloworld/32/101738_2.png) [@404HelloWorld](https://forum.freecodecamp.org/u/404HelloWorld)\
**Post date:** [January 7, 2018, 6:55pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/1 "2018-01-07T18:55:45Z")

</div>

**Tell us what’s happening:**

**Your code so far**

```auto
var myStr = "FirstLine\n\\SecondLine\\\rThridLine"; // Change this line

var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (X11; CrOS armv7l 10032.75.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.116 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/escape-sequences-in-strings](https://www.freecodecamp.org/challenges/escape-sequences-in-strings)

---

<div class="post-metadata">

**Author:** ![404HelloWorld](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/404helloworld/32/101738_2.png) [@404HelloWorld](https://forum.freecodecamp.org/u/404HelloWorld)\
**Post date:** [January 7, 2018, 7:02pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/2 "2018-01-07T19:02:35Z")

</div>

🤔

I have been to several different links online! I have tried this problem 10 different ways and it does NOT PASS THE CODE. Why are people saying check capitals??? If the solution they post doesn’t work in (l vs L). Or (“” vs ‘’)!

New line = \n right?  
Backslash = \\ right?  
Carriage-return = \r right?

So what is going wrong here. There are people on all three sites posting the wrong answer/solution. An when people try to explain their reasoning it doesn’t work. The instructions are below. I’m so lost. Someone please in Clear English without playing games…  
Tell me what I’m not understanding.  
I have checked spelling, CameLCase, and double quotes. And it still doesn’t pass mustard.

Sigh

/\*  
Instructions  
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine  
\SecondLine  
ThirdLine  
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine  
\*/

Check out the following links:

> **[GitHub - freeCodeCamp/freeCodeCamp: freeCodeCamp.org's open-source codebase...](https://github.com/freeCodeCamp/freeCodeCamp)**
>
> freeCodeCamp.org's open-source codebase and curriculum. Learn to code for free. - GitHub - freeCodeCamp/freeCodeCamp: freeCodeCamp.org's open-source codebase and curriculum. Learn to code f...

> [@freeCodeCamp Challenge Guide: Escape Sequences in Strings](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-escape-sequences-in-strings/17567/28):
>
> Oh my goodness! Spelling and attention to detail counts. I couldn’t figure out why it wasn’t working until I saw your post and reviewed my code. I went nuts for a minute.

> <https://stackoverflow.com/questions/38516442/what-is-wrong-with-my-code-in-this-escape-sequences-in-strings-challenge-on-fr>

---

<div class="post-metadata">

**Author:** ![TomerPacific](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tomerpacific/32/158967_2.png) [@TomerPacific](https://forum.freecodecamp.org/u/TomerPacific)\
**Post date:** [January 7, 2018, 7:10pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/3 "2018-01-07T19:10:50Z")

</div>

@404HelloWorld,  
I don’t see anything wrong with your code.

I wrote the following in the challenge and it worked

“FirstLine\n\SecondLine\\rThirdLine”

What errors are you getting?

---

<div class="post-metadata">

**Author:** ![404HelloWorld](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/404helloworld/32/101738_2.png) [@404HelloWorld](https://forum.freecodecamp.org/u/404HelloWorld)\
**Post date:** [January 7, 2018, 7:12pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/4 "2018-01-07T19:12:47Z")

</div>

Hi thanks for responding!!!

This is the error.

myStr should have encoded text with the proper escape sequences and no spacing.

The rest of the objectives are Green!

---

<div class="post-metadata">

**Author:** ![TomerPacific](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tomerpacific/32/158967_2.png) [@TomerPacific](https://forum.freecodecamp.org/u/TomerPacific)\
**Post date:** [January 8, 2018, 5:52pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/5 "2018-01-08T17:52:04Z")

</div>

try pasting the solution I wrote and see if you pass the test.

---

<div class="post-metadata">

**Author:** ![ALBERSABER](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/albersaber/32/86325_2.png) [@ALBERSABER](https://forum.freecodecamp.org/u/ALBERSABER)\
**Post date:** [May 14, 2018, 3:57pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/6 "2018-05-14T15:57:50Z")

</div>

i stucked with it but finally i tried that and it works  
var myStr = “FristLine\n”+"\SecndeLine\" +"\rThirdLine";

---

<div class="post-metadata">

**Author:** ![citizen0x](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/citizen0x/32/91408_2.png) [@citizen0x](https://forum.freecodecamp.org/u/citizen0x)\
**Post date:** [June 20, 2018, 3:23pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/7 "2018-06-20T15:23:08Z")

</div>

“FirstLinenewlinetabbackslashSecondLinenewlineThirdLine”  
newline = \n  
tab = \t  
backslash = \\  
“FirstLine\n\t\\SecondLine\nThirdLine”;

---

<div class="post-metadata">

**Author:** ![JayPret](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@JayPret](https://forum.freecodecamp.org/u/JayPret)\
**Post date:** [July 23, 2019, 3:53pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/8 "2019-07-23T15:53:27Z")

</div>

I did the following and it liked it.  
myStr = “FirstLine\n\t\SecondLine\nThirdLine”; // Change this line

---

<div class="post-metadata">

**Author:** ![Frankzhac](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@Frankzhac](https://forum.freecodecamp.org/u/Frankzhac)\
**Post date:** [July 23, 2019, 7:36pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/9 "2019-07-23T19:36:42Z")

</div>

Here’s the answer:

```auto
<redacted>

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [July 23, 2019, 7:37pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/10 "2019-07-23T19:37:57Z")

</div>

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

If you want to compare your solution to others, use the Get a hint button on the challenge and there are alternative solutions you can compare yours to. Also, you can probably search older posts using the forum search feature or google the challenge name and find more there.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

---

<div class="post-metadata">

**Author:** ![tiroloquo](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@tiroloquo](https://forum.freecodecamp.org/u/tiroloquo)\
**Post date:** [July 23, 2019, 8:31pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/11 "2019-07-23T20:31:11Z")

</div>

where in the challenge did it ask for a carrige return? and where is your TAB?

---

<div class="post-metadata">

**Author:** ![Starnold](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/starnold/32/135268_2.png) [@Starnold](https://forum.freecodecamp.org/u/Starnold)\
**Post date:** [July 25, 2019, 5:12am UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/12 "2019-07-25T05:12:11Z")

</div>

Work on the problem one at time, and pay attentiont to the output window. For example:

1. I applied the ‘newline’ first, then watched as the string starts to line up vertically in the output window:  
FirstLine  
SecondLine  
ThirdLine

2. Looking back at the requirement, the SecondLine appears indented, so apply ‘tab’  
FirstLine  
\_\_\_\_\_\_SecondLine  
ThirdLine

3. Finally applying backslash to SecondLine. I watched it change in the output window into the final required output.  
FirstLine  
\_\_\_\_\_\_\SecondLine  
ThirdLine

4. Review for case sensitivity check, then submit.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 25, 2021, 12:24pm UTC](https://forum.freecodecamp.org/t/escape-sequences-in-strings-not-working/167350/14 "2021-01-25T12:24:36Z")

</div>

Closed on January 25, 2021, 12:24pm UTC


