# The Sword of Syntax

## Ternary Conditionals

The ternary conditional provides a shortcut over lengthier conditional blocks.

Example

Caution

The + only knows to evaluate a variable and add it to a string, all before the ? gets to check a condition.

The ? now looks for a boolean, but finds a string. Turns out, any JS value that is not false, 0, undefined, NaN, "", or null will always evaluate as “truthy”.

Ensure ternaries are isolated
Use parentheses to ensure the conditional is checked correctly.

More Usage

• We can use compound Boolean expressions to make ternary decisions, too.

• Any executable statement can serve as a ternary?s response choices.

• Ternaries provide a different format for picking immediately-invoked functions.

• Each result option provides the opportunity to execute multiple actions.

• A ternary can hold other ternaries within each of the possible responses.

To be continued.