< Back
Page 8 of 8
This chapter is from the book
Workshop
The workshop contains quiz questions and exercises to help you solidify your understanding of the material covered. Try to answer all questions before looking at the “Answers” section that follows.
Quiz
When a user views a page containing a JavaScript program, which machine actually executes the script?
- The user’s machine running a web browser
- The web server
- A central machine deep within Netscape’s corporate offices
What tool do you use to create and edit JavaScript programs?
- A browser
- A text editor
- A pencil and a piece of paper
What are variables used for in JavaScript programs?
- Storing numbers, dates, or other values
- Varying randomly
- Causing high-school algebra flashbacks
What should appear at the very end of a JavaScript script embedded in an HTML file?
- The
<script
type
="text/javascript"
> tag - The
</script>
tag - The END statement
- The
Answers
- a. JavaScript programs execute on the web browser. (There is actually a server-side version of JavaScript, but that’s another story.)
- b. Any text editor can be used to create scripts. You can also use a word processor if you’re careful to save the document as a text file with the .html or .htm extension.
- a. Variables are used to store numbers, dates, or other values.
- b. Your script should end with the
</script>
tag.
Exercises
- Add a millisecond field to the large clock. You can use the getMilliseconds function, which works just like getSeconds but returns milliseconds.
- Modify the script to display the time, including milliseconds, twice. Notice whether any time passes between the two time displays when you load the page.
< Back
Page 8 of 8