You are able to use single quotes or double quotes in JavaScript. The following quotes can be used to create string variables:
var weakHero = 'Superman';
var strongHero ="Hulk";
Single quotes and double quotes are interchangeable, but be careful.
A problem you might encounter is using quotes within quotes. Say for example you want to use the following alert boxes:
<script language="Javascript" type="text/javascript">
// Display alert boxes
window.alert("The Hulk says, 'Hulk Smash!'");
window.alert('Superman says, "Hulk is too powerful for me!"');
</script>
Notice that you have to place single quotes within double quotes (or vice-versa).
The above code is correct, but you can't do the following:
<script language="javascript" type="text/javascript">
// Display alert boxes
window.alert("The Hulk says, "Hulk Smash!"");
window.alert('Superman says,'Hulk is too powerful for me!'');
</script>
Do you see the problem above? Try to code it. It will generate an error. JavaScript doesn't know when to begin the quote within the quote.
For this assignment, create an alert box that displays a quote. Make sure to include quotation marks within your alert.