Sams Teach Yourself JavaScript in 24 Hours

Sams Teach Yourself JavaScript in 24 Hours

By Michael Moncur

Quiz

Test your knowledge of the JavaScript techniques you used in this hour by answering the following questions.

Questions

1:

Which array can you use to change images in a Web page?

  1. this
  2. document.src
  3. document.images
A1:

c. The document.images array can be used to change images on a page.

2:

Which of the following is the correct expression for a random integer between 1 and 52?

  1. Math.random(52)
  2. Math.floor(52*Math.random() + 1)
  3. Math.floor(52*Math.random())
A2:

b. Because the Math.random method returns a number between 0 and 1, the correct expression is Math.floor(52*Math.random() + 1).

3:

What are the odds of being dealt a royal flush while playing this game?

  1. 1 in 5,000
  2. 1 in 50,000
  3. 1 in 500,000
A3:

c. The odds are about one in half a million, but I didn't really expect you to know that offhand.

Share ThisShare This

Informit Network