What does a Boolean expression produce?
A Boolean expression evaluates to exactly one of two logical values: true or false.
Study 04 Conditionals and Boolean Logic with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What does a Boolean expression produce?
A Boolean expression evaluates to exactly one of two logical values: true or false.
Which operators test strict equality and inequality?
Use === for strict equality and !== for strict inequality in JavaScript. Strict comparisons avoid the type conversions associated with == and !=.
How does >= differ from > at a boundary?
The condition score >= 60 accepts 60 itself; score > 60 excludes 60 and requires a greater value.
When is an AND condition true?
The && operator is true only when both combined Boolean expressions are true.
When is an OR condition true?
The || operator is true when at least one combined Boolean expression is true, including when both are true.
What does the NOT operator do?
The ! operator reverses a Boolean result: !true is false, and !false is true.
Why use parentheses in complex conditions?
Parentheses make the intended grouping explicit, especially when && and || appear together.
What does a basic if statement do?
An if statement runs its block when its condition is true; if the condition is false, the block is skipped.
What is the behavior of if...else?
An if...else statement provides two alternatives, and exactly one branch runs after the condition is evaluated.
How does an else if chain choose a branch?
An else if chain tests conditions from top to bottom; after the first true condition, its block runs and later branches are skipped.
What is a nested conditional?
A nested conditional is a conditional inside another conditional. The inner decision is considered only when the outer condition allows it.
When is switch preferable to if...else if?
Use switch when branches compare one expression with several exact expected values. Use if...else if for ranges or complex Boolean expressions.