Create a new document. Place the following code in the body of your document. Then save and preview. What happens?
<script type="text/javascript">
alert("Hello, world!");
</script>
Change the "Hello, world!" to numbers, like the ones below. Then save and preview. What happens?
<script type="text/javascript">
alert("2+2");
</script>
Remove the quotation marks, like in the example below. Then save and preview. What happens? Try removing the quotation marks from "Hello, world!" in Example 1.
<script type="text/javascript">
alert(2+2);
</script>
Try including both letters and numbers, like in the example below. Then save and preview. What is the "+" doing? Try removing it to see what happens.
<script type="text/javascript">
alert("Here is a number: " + 2);
</script>
Try the example below. Then save and preview. Can you explain the result?
<script type="text/javascript">
alert("Here is a sum: " + 2 + 2);
</script>
Try the example below. Then save and preview. Does this work better? How could you add a period at the end?
<script type="text/javascript">
alert("Here is a sum: 978 + 2369 = " + eval(978 +
2369) );
</script>
Move the code into the head of your document. Then save and preview. What happens?