Docsity

CSCI 2910 JavaScript Syntax Quiz - Spring 2007 - Prof. David L. Tarnoff, Quizzes of Computer Science

Toggle sidebar
bg1
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? __4 times____
for (i = 0; i < 10; i = i +3)
document.writeln("i = " + i + "\n");
If inserted into an XHTML file, the above code will output the following text:
i = 0
i = 3
i = 6
i = 9
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: ____________
The following is from the PowerPoint lecture slides from last Thursday:
\n newline
\t tab
\r carriage return
\\ backslash
\" double quote
\' single quote
6. True or false: JavaScript is case sensitive.
7. Name one of the benefits discussed in class of an interpreted language.
• Interpreted programming language can run on any platform or O/S as long as there is an interpreter that runs on
that particular setup.
• Server processing time is saved by not having to run scripts
• May be faster in cases where communication with server is eliminated
pf2

Partial preview of the text

Download CSCI 2910 JavaScript Syntax Quiz - Spring 2007 - Prof. David L. Tarnoff and more Quizzes Computer Science in PDF only on Docsity!

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 tag of an XHTML file

  1. Each line of a JavaScript program must be terminated with the character _______.

a.) / b.) > c.) # d.) < e.) ~ f.). g.) ; h.) :

  1. Modify the code below so that browsers that do not support JavaScript will ignore the code.
  1. How many times will the code inside the following for-loop be executed? __4 times____

for (i = 0; i < 10; i = i +3) document.writeln("i = " + i + "\n"); If inserted into an XHTML file, the above code will output the following text: i = 0 i = 3 i = 6 i = 9

  1. 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: ____________ The following is from the PowerPoint lecture slides from last Thursday: \n newline \t tab \r carriage return \ backslash " double quote ' single quote

  1. True or false: JavaScript is case sensitive.
  2. Name one of the benefits discussed in class of an interpreted language.
    • Interpreted programming language can run on any platform or O/S as long as there is an interpreter that runs on that particular setup.
    • Server processing time is saved by not having to run scripts
    • May be faster in cases where communication with server is eliminated
  1. Name one of the drawbacks discussed in class of an interpreted language.
    • Slower for processing
    • Cannot hide code from end user
  2. 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!');"