Conditional Statements Flashcards

1
Q

An __? statement checks a condition and will execute a task if that condition evaluates to be __?.

A

An if statement checks a condition and will execute a task if that condition evaluates to true.

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

____? and ___? statements make binary decisions and execute different code blocks based on a provided condition.

A

if…else statements make binary decisions and execute different code blocks based on a provided condition.

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

We can add more ____? using ___? statements.

A

We can add more conditions using else if statements.

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

Comparison operators, including __,__, __,__,__, and ___? can compare two values

A

Comparison operators, including
<, >, <=, >=, ===, and !==
can compare two values

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

The logical and operator, __?, or __?, checks if both provided expressions are truthy.

A

The logical and operator,
&&, or “and”,
checks if both provided expressions are truthy.

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

The logical operator, _____? checks if either provided expression is truthy.

A
The logical operator 
||, or “or”, 
checks if either provided expression is truthy.
true || false;        // true
10 > 5 || 10 > 20;    // true
false || false;       // false
10 > 100 || 10 > 20;  // false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The ___? operator, ___?, switches the truthiness and falsiness of a value.

A

The
bang operator, !,
switches the truthiness and falsiness of a value.

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

There is also a short-hand if else, which is known as the _____? operator because it consists of three operands. The _____ operator allows for a compact syntax in the case of binary (choosing between two choices) decisions. It accepts a condition followed by a __ operator, and then two expressions separated by a __ If the condition evaluates to truthy, the first expression is executed, otherwise, the second expression is executed.

A

There is also a short-hand if else, which is known as the ternary operator The ternary operator allows for a compact syntax in the case of binary (choosing between two choices) decisions. It accepts a condition followed by a ? operator, and then two expressions separated by a :. If the condition evaluates to truthy, the first expression is executed, otherwise, the second expression is executed.
Example
let price = 10.5;
let day = “Monday”;
day === “Monday” ? price -= 1.5 : price += 1.5;

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

Java ____? Statements

Use the ____? statement to select one of many code blocks to be executed.
The ____? keyword stops the remaining cases from being checked and executed in a ___?

A
Java Switch Statements
Use the switch statement to select one of many code blocks to be executed.
switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly