Sams Teach Yourself JavaScript in 24 Hours

Sams Teach Yourself JavaScript in 24 Hours

By Michael Moncur

Quiz

Test your knowledge of conditional statements in JavaScript by answering the following questions.

Questions

1:

What does the statement if (fig==1) do?

  1. Assigns the variable fig the value 1.
  2. Displays an error message because the names of fruits cannot be used as variable names.
  3. Checks fig for a value of 1 and performs an action if it matches.
A1:

c. This statement checks the fig variable and performs an action if its value is 1.

2:

Which of the following operators means "is not equal to" in JavaScript?

  1. !
  2. !=
  3. <>
A2:

b. The != operator means is not equal to.

3:

What does the switch statement do?

  1. Tests a variable for a number of different values.
  2. Turns a variable on or off.
  3. Makes ordinary if statements longer and more confusing.
A3:

a. The switch statement can test the same variable or expression for a number of different values.

Share ThisShare This

Informit Network