Sparky saysThe ternary operator condition ? a : b is a compact inline if/else that returns a value.
age >= 18 ? "adult" : "minor" picks one of two values based on a condition. It's an expression (returns a value), so it fits inside template literals, JSX, and assignments. Keep it to simple choices — nested ternaries quickly become unreadable; use if/else then.
Power-ups you unlock
condition ? valueIfTrue : valueIfFalse
It’s an expression — returns a value
Great inside templates and assignments
Avoid deep nesting (use if/else)
NaN the Trickster attacks — common mistakes
Nesting ternaries into unreadable chains
Using a ternary for side effects (use if)
Forgetting it returns a value, not runs a block
Boss battleSet a label with a ternary based on a number being even or odd.