Home > Articles

  • Print
  • + Share This
This chapter is from the book


The workshop contains quiz questions and exercises to help you solidify your understanding of the material covered.


  1. When a user views a page containing a JavaScript program, which machine actually executes the script?

    1. The user’s machine running a web browser

    2. The web server

    3. A central machine deep within Netscape’s corporate offices

    4. A dedicated JavaScript server

  2. What software do you use to create and edit JavaScript programs?

    1. A browser

    2. A text editor

    3. A pencil and a piece of paper

    4. A JavaScript editor

  3. What are variables used for in JavaScript programs?

    1. Storing numbers, dates, or other values

    2. Varying randomly

    3. Causing high-school algebra flashbacks

    4. Changing the output of the script

  4. What should appear at the very end of a JavaScript script embedded in an HTML file?

    1. The <script> tag

    2. The </javascript> tag

    3. The END statement

    4. The </script> tag

  5. Which of these is not something you can do with JavaScript?

    1. Detect the features of the browser in use

    2. Modify part of a page without requiring a page refresh

    3. Write data to the remote server

    4. Interact with data from a remote server

  6. Where can you place scripts?

    1. In the body of a page

    2. Within an HTML tag

    3. In a separate file

    4. All of the above

  7. What do you use to include a separate script file in a page?

    1. <link src="filename.js">

    2. <script src="filename.js"></script>

    3. <javascript src="filename.js">

    4. <include src="filename.js"></include>

  8. Which of these is an event handler?

    1. <button>

    2. type="button"

    3. onclick="alert('You clicked the button.')"

    4. </button>

  9. What does the line now = new Date(); do in JavaScript?

    1. It creates a variable called now and stores the current date in it.

    2. It creates a variable called new and stores the current date in it.

    3. It displays the current time.

    4. Nothing; it’s not valid JavaScript.

  10. Correct this line of JavaScript:

    document.write("<p><strong>Dinner Time:</strong> " + localtime + "</p>);
    1. document.write("<p><strong>Dinner Time:</strong> " + localtime + "</p>");

    2. document.write("<p><strong>Dinner Time:</strong> " + localtime + "</p>');

    3. document.write("<p><strong>Dinner Time:</strong> " + localtime + "</p>;

    4. The line is correct as written.


  1. a. JavaScript programs execute in the web browser. (There is actually a server-side version of JavaScript, but that’s another story.)

  2. b. You can use any text editor to create scripts.

  3. a. Variables are used to store numbers, dates, or other values.

  4. d. Your script should end with the </script> tag.

  5. c. JavaScript can never write data to the remote server due to security concerns.

  6. d. JavaScript can be added in the body, a tag, or in a separate file.

  7. b. Use the line <script src="filename.js"></script>.

  8. c. The onclick attribute and its value are the click event handler.

  9. a. It creates a variable called now and stores the current date in it.

  10. a. The final quotation mark is missing.

  • + Share This
  • 🔖 Save To Your Account