Ternary Operator Syntax
Multiple Choice Beginner
Question
Which is the correct ternary operator syntax?
Hint
The question mark comes first, then colon separates the two outcomes.
Explanation
The ternary operator syntax is condition ? valueIfTrue : valueIfFalse. It is a shorthand for if/else that returns a value. For example, let status = age >= 18 ? "adult" : "minor" assigns "adult" or "minor" based on the condition.
Related Resources
Related Lessons
- Conditions (if/else)
Learn how if/else conditions work.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.