Free Online Flashcard Deck

3 Conditionals and Boolean Logic Free Online FlashCards

Study 3 Conditionals and Boolean Logic with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What two values can a JavaScript Boolean have?

Back

A Boolean has exactly two values: `true` and `false`.

02
Front

Which JavaScript values are commonly falsy?

Back

Common falsy values include `false`, `0`, `""`, `null`, `undefined`, and `NaN`. Empty arrays and objects are truthy.

03
Front

Why prefer `===` and `!==` in JavaScript?

Back

Use `===` for strict equality and `!==` for strict inequality. They do not automatically convert one type into another.

04
Front

What ordering does JavaScript use when comparing strings?

Back

JavaScript compares strings according to Unicode ordering, which may not match dictionary order in every language.

05
Front

When is `&&` true?

Back

The `&&` operator is true only when both conditions are true. Use it when all requirements must be satisfied.

06
Front

When is `||` true?

Back

The `||` operator is true when at least one condition is true. Use it when any acceptable alternative is sufficient.

07
Front

What does the `!` operator do?

Back

The `!` operator reverses a Boolean value: `!true` is `false`, and `!false` is `true`.

08
Front

How does JavaScript short-circuit logical expressions?

Back

With `&&`, a falsy left operand skips the right side; with `||`, a truthy left operand skips the right side.

09
Front

How does `??` differ from `||` for default values?

Back

`??` uses the fallback only for `null` or `undefined`, whereas `||` uses it for every falsy value, including `0` and `""`.

10
Front

What does an `if...else` statement choose?

Back

An `if...else` statement runs the `if` block when its condition is truthy; otherwise, it runs the `else` block.

11
Front

How are `else if` branches evaluated?

Back

JavaScript tests an `else if` chain from top to bottom and runs only the first truthy branch. Put more specific or higher-priority tests first.

12
Front

When is the ternary operator appropriate?

Back

The ternary form is `condition ? valueIfTrue : valueIfFalse`. Use it for a short two-way value choice; use `if...else` for multiple actions.