@anon22924398 it’s awesome you want to help, but your explanation is completely unrelated from the challenge mentioned here, maybe check which challenge campers are asking about?
BTW, in the case you need an explanation of the reply, it is this:
the exercise asks to write a string escaping quotes. I thought the OP wanted to include variables also, which should probably work as a solution. I may be wrong, but it is not
but your explanation is completely unrelated from the challenge mentioned here
There is a slight missunderstanding.
OP actually tries to solve the challenge - your advice builds upon the code OP wrote, but this code is just wrong in the context of the challenge and your admirable effort to help runs the risk of confusing OP more than helping. That’s why I assume @ilenia wrote here and not privatly. So OP knows that what your wrote is not wrong, but won’t help solve the challenge
Please read the challenge again - you are supposed to use special characters in this challenge.
First, don’t declare variables like FirstLine and so on - while @anon22924398 showed you how you can use those in strings, you don’t need them for this challenge.
What you need are escape-characters as listed in the task.
For examle, the string "Thing\tding" will be turned into Thing ding → the \t is replaced by a tab-space. Same for linebrakes and others. If there is a \ then the interpreter (the thing that reads JavaScript commands) will take the following letter and turn both into new behavior (like adding linebreaks or tabspaces).
So Hello_\nWorld will be logged as
Well, it is your interpretation and ‘your admirable effort’ is not a respectful reply.
Also, missunderstanding doesn’t exist my friend, unless you went to far as to make a joke. XD
You’re very ready to help users and not to be polite to other helpers. Sorry, I just don’t really follow your deep ideas there.
What “finished product”? The code you wrote throws a syntax error because you tried to split the string over several lines but JavaScript expects the string to end on the same line it started: SyntaxError: unknown: Unterminated string constant. (1:11)
(1:11) meaning first line, 11th character.
Ok so you seemingly solved the challenge, right? Looks good.
Now there are two reasons, why you cannot change the text. First is the fact you declare the variables AFTER you want to use them. Code is executed from top to bottom, so you cannot expect JavaScript to use a variable before declaring it.
Second is what @santimir already adressed. If you want to combine variables with strings, you have to tell JavaScript that you are using a variable. JS will assume everything inside of quotes is plain text → it will not try to find a variable that might be called like a part of the string.
Everyone please remember that there is a human on the other end of the keyboard.
The initial problem in the first post wasn’t clearly described, so it’s understandable that people tried to help OP solve the challenge. That’s what the Ask For Help button is intended for.
Let’s not derail the conversation with demands for justice please.
If you want to talk to a specific person about how you feel they talked to you, that’s a great time to use direct messages. This topic is for OP’s question.
@roemergb if you want to use variables that hold strings, you should go back to the Word Blanks challenge and review how it was done there.