5.11.1 Javascript Control Structures Quiz

Question: Which of the following is not a valid value for a boolean?

True

False

Yes

The above are all valid

Answer: Yes

Question: What symbol represents the or operator in JavaScript?

OR

or

|

||

Answer: ||

Question: What symbol represents the and operator in JavaScript?

AND

and

&

&&

Answer: &&

Question: After the following code runs, what is the value of isWeekend?

var isSaturday = true;

var isSunday = false;

var isWeekend = isSaturday || isSunday;

true

false

“isWeekend”

“isSaturday || isSunday”

Answer: True

Question: What is the proper operator for “not equals” in JavaScript?

=!

!=

~=

NOT EQUALS

Answer: !=

Question: What is the proper way to compare if two values are equal in a boolean expression in JavaScript?

=

==

EQUALS

is

Answer: ==

Question: How can we check if a variable num is even?

num.isEven() will be true

(num % 2 == 0) will be true

(num % 2 == 0) will be false

(num / 2 == 0) will be true

Answer: (num % 2 == 0) will be true

Question: What kind of statement allows us to run one block of code if one condition is true, and a separate block of code otherwise?

if statement

break statement

if/else statement

for loop

Answer: if/else statement

Question: What kind of statement allows us to run a block code only if a certain condition is true?

if statement

break statement

else statement

for loop

Answer: if statement

Question: How many times will the following program print “hello”?

for (var i = 0; i < 5; i++) {

println(“hello”);

}

4

5

6

i

Answer: 5

Donation Page

Support Our Work

Do you appreciate the value this website provides? If so, please consider donating to help keep it running. Your donation will go a long way in helping us continue to provide the same quality of content and services. Every bit helps, and your support is greatly appreciated. Thank you for your generosity.