Skip to content

Glossary: JavaScript Basics

Conditional operator

Also written: ternary operator, ? :, a ? b : c

A one-line choice, `condition ? a : b`, which gives `a` when the condition is truthy and `b` otherwise, like choosing `"bag"` or `"bags"`.

Where the book teaches it