Testing sets of conditions Flashcards

1
Q

Type the operator that means and.

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Type the operator that means or.

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When both sides of an operator have to be true to pass the test, what operator is it? Type it.

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When, if either or both sides of an operator is (are) true, the test passes, what operator is it? Type it.

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Code the first line of an if statement that tests whether both are true: a has the same value as b and c has the same value as d.

A

if (a === b && c === d) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Code the first line of an if statement that tests whether either or both are true: a has the same value as b or c doesn’t have the same value as d.

A

if (a === b || c !== d) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Code the first line of an if statement that tests whether both are true: a first variable equals a second variable and also equals a third variable.

A

if (a === b && a === c) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Code the first line of an if statement that tests whether either is true: a variable is less than or equal to a particular number or whether that same variable is greater than or equal to a second number.

A

if (a <= 10 || a >= 12) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Code the first line of an if statement that tests whether (1) name is either “Ace” or “Bud” and (2) age is greater than 60.

A

if ((name === “Ace” || name === “Bud”) && age > 60) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Code the first line of an if statement that tests whether (1) name is “Ace” and age is greater than 60 or (2) name is “Bud”.

A

if ((name === “Ace” && age > 60) || name === “Bud”) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Code the first line of an if statement that tests whether (1) name is “Ace” and age is greater than 60 or (2) name is “Bud” or age is under 6.

A

if ((name === “Ace” && age > 60) || (name === “Bud” || age < 6)) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly