I want a javascript alert that reads, "It's "Hammer" time!"
What is the best code to write this?
I want a javascript alert that reads, "It's "Hammer" time!"
What is the best code to write this?
Although you could use a string with '
and escape the '
, or a string with "
and escape the "
s, it would be better to use a template literal, which doesn't require escaping of quotes because its delimiter is the backtick:
alert(`"It's "Hammer" time!"`);
For displaying single or double quotes, you can write your code like this alert("\"It's \"Hammer\" time!\"")
Escape the "s
other than the ones from the begining and ending..
alert("\"It's \"Hammer\" time!\"")
How to display double quotes in JavaScript
Or use string interpolation, where you can have both without escaping.
alert(`Hello, I'm "nobody"!`);