As @Marmiz mentioned, you’re using a forward slash. To escape characters you use a backslash (\) in JavaScript.
const myStr = "I am a \"double quoted string inside double quotes\".";
You don’t need to escape single-quotes in a double-quote string. Nor vice versa. You just need to escape the same quote style as you’re using to define the string. And, with double quotes, certain special characters if applicable.
// Double-quoted string
const doubleQuote = "As a double-quoted string, \"double quotes\" inside me need to be escaped, but single-quotes, like in 'you're', are okay alone.";
// Single-quoted string
const singleQuote = 'And vice versa... in a "single quote string", like you\'re going to need to escape single quote characters, like I just did in the word "you\'re", but I can use double quotes freely.';
let s1 = 'I am a valid string';
let s2 = "I am a valid sting too"
Notie that you cannot mix them If you start with a single quote, it has to finish with a single quote as well, otherwise the JS interpreter cannot understand that the string is terminated:
let s = 'I end with a double"
// SyntaxError: Unterminated string constant
That said, if you want to use a the same quote inside the string as punctuation, you need to escape it, otherwise the JS interpreter don’t have a way to tell it’s punctuation opposed to end of the string
let z = 'It's a miracle'
// SyntaxError: Unexpected token
This happens because JS thinks the string ends at it's... (a single quote)
Same for double quotes.
you can use string literal or template literal for any string like below:
Enclose string inside tilt(`) symbol instead of quotes. This makes string look clean and neat and solves many problems.
let z = ` It’s a miracle `;