Tell us what’s happening:
Describe your issue in detail here.
Your code so far
const myStr = "FirstLine\n\t\\SecondLine\nThirdLine"; // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Escape Sequences in Strings
Link to the challenge:
Learn to Code — For Free
enlguy
July 18, 2023, 10:56am
2
This is correct… you don’t describe an issue, either… Not sure what you’re posting about.
itisi
July 18, 2023, 10:59am
3
A populare issue, isn’t it
The text FirstLine should be followed by the code for newline, tab, and backslash.
The text SecondLine should be followed by the code for newline.
The text ThirdLine should just be at the end of the string.
It should be one big string all connected with no spaces.
Example:
const myStr = "\tProduct\nPizza\tPrice\t10\\$";
console.log(myStr)
Product
Pizza Price 10\$
and a summary:
Here’s what I find in the challenge:
FirstLine
\SecondLine
ThirdLine
Let me put it differently:
FirstLine[NEWLINE]
[TAB][LITERALLY]\SecondLine[NEWLINE]
ThirdLine
[LITERALLY] of course means, that the following character is to be taken as such (literally) and not interpreted as a control character, or as they say in the trade, the character needs to be escaped .
So, what character do you use in JS to replace the “[LITERALLY]”?
Or in one single line:
FirstLine[NEWLINE][TAB][LITERALLY]\SecondLine[NEWLINE]ThirdLine
Reading Educates