
The ternary operator is a one-line shorthand for a simple if/else: condition ? valueIfTrue : valueIfFalse. Example: const label = age >= 18 ? 'Adult' : 'Minor';. Use it for simple, readable assignments. Avoid nesting ternaries — once you need a nested ternary, use a regular if/else statement for clarity.
Reference:
TaskLoco™ — The Sticky Note GOAT