Say we want to log a string: console.log("hi"). That logs hi but how do we log literally "hi"? Because the JS interpreter will use quotes to delimit where the string starts and end, but won’t display them.
Hence, it is need to tell the interpreter that those quotes are to be displayed, and not for defining a string type. That’s done with backslashes before the quote \".
It’s also worth notice that the \ has a special meaning. Try using \t, for example.
How would you display “hi”, then?
Yeah, the console output is odd on this one. It shows:
myStr = "I am a "double quoted" string inside "double quotes""
It is parroting back your code with the right half having the escape \s removed and surrounding quotes? Yeah, that looks odd to me.
It would be like the result of:
console.log("myStr = " + "\"" + myStr + "\"");
// myStr = "I am a "double quoted" string inside "double quotes""
adding some extra stuff in there, to make it pretty. But it looks odd to me because it almost looks like code - something we don’t normally see in the console.
A more bare bones logging like:
console.log(myStr);
// I am a "double quoted" string inside "double quotes"
I mean, there is nothing wrong with it, per se, but I could see how that phantom logging, in an odd format might confuse the uninitiated.
I just want you to check that piece of challenge and you will find out what wrong ! just go to that link and do what it needs and then you will find out the console shows odd behave in this challenge