I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
So you’ve got the backslashes handled, kudos. But the thing biting you now is a common problem - when you open a quote, whether single quote ( ' ) or double quote ( " ), it has to have a match. You can’t open a quote and not close it. Javascript refers to that as an unterminated String, and it causes javascript some confusion.
See how, right after the var myStr =, you have that single quote mark? Where’s its buddy?
The point of this lesson is, within a single-quote string, you can embed double quotes without needing to do some special escape trick. Or, within a double-quoted string, you can use single quotes as though they’re just a normal character. But if you surround a string with single quotes and try to embed that single quote, you have to ‘escape’ it with the backslash.
For example, 'This isn\'t a number, it\'s a string' - in order to use the apostrophe in there, I had to either use the backslash, OR replace the surrounding quotes with double quotes: `“This isn’t a number, it’s a string” is fine.
There are some characters that have special significance in a programming language. For example, within a string surrounded by quotation marks ( "..."), I couldn’t have a quotation mark without some fancy footwork: "The story goes, \"Once upon a time...\" ... and on and on" <-- in that string, the quote marks WITHIN the quote have been ‘escaped’ by leading with a backslash. I’ve told javascript’s String interpreter, “The next character is a part of the string, and not the END of the string.”