
Name: ________________________________
CSCI 2910 JavaScript Syntax Quiz
Spring 2007
1. In which of the following locations can JavaScript code be placed? Circle all that apply.
a.) In the head of an XHTML file
b.) In a separate text file
c.) In the body of an XHTML file
d.) As an attribute of an XHTML tag
e.) After the </body> tag of an XHTML file
2. Each line of a JavaScript program must be terminated with the character _______.
a.) / b.) > c.) # d.) < e.) ~ f.) . g.) ; h.) :
3. Modify the code below so that browsers that do not support JavaScript will ignore the code.
<script language="javascript" type="text/javascript">
document.writeln("<h1>Hello, World!</h1>");
</script>
4. How many times will the code inside the following for-loop be executed? ___________
for (i = 0; i < 10; i = i +3)
document.writeln("i = " + i + "\n");
5. The \n in the previous question represents an escape character that outputs a carriage return. Give another
example of an escape character along with the expected output.
Escape character: ______________ Expected output: ____________
6. True or false: JavaScript is case sensitive.
7. Name one of the benefits discussed in class of an interpreted language.
8. Name one of the drawbacks discussed in class of an interpreted language.
9. For each of the lines of JavaScript code below, place a single underline beneath the objects, place a double
underline beneath the attributes (properties), circle the methods, and put brackets, [ ], around the events.
history.length;
onClick="window.alert('You found it!');"