Ans: (1) In an onclick attribute, (2) within script tags in the head or body.
Ans: It is a function that is called in an onclick statement.
<html> <body> <h1>Humphrey Bogart Quote</h1> <script type="text/javascript"> var name = "Sam"; document.write("<p>Play it again, " + name + ".</p>"); </script> <body> </html>Ans: Play it again sam.
Ans: Integer (e.g., 3465), floating point (e.g., 3.14159), string (e.g., "Hello") boolean (true or false).
Ans: It means declaring and assigning a value to a variable
in one statement like this:
var x = 5;.
abc b768 4slots hook&ladder numberOfCustomers number-of-customers anExtremelyLongVariableNameIfYouAskMeAns: abc (legal) b768 (legal) 4slots (not legal) hook&ladder (not legal) numberOfCustomers (legal) number-of-customers (not legal) anExtremelyLongVariableNameIfYouAskMe (legal, but too long to be easy to read)
Ans: Each new word within a variable name is spelled in upper case.
Ans: + (addition or concatenation) - * / =
Ans: To put two character strings together to make one longer string.
document.write(1 + 2 + "<br />"); document.write("1" + "2" + "<br />"); document.write("1" + 2 + "<br />"); document.write(1 + "2" + "<br />"); document.write(1 + 2 + "3" + 4 + 5 + "<br />");Output:
3 12 12 12 3345
When you get stuck, read the next section on debugging with Mozilla. Use Mozilla to find the rest of the errors.
Ans: See the Distance2 Example