Ternary Render
Predict Output Easy
Question
What does this code print?
Code
function App() {
const age = 16;
return <p>{age >= 18 ? "Adult" : "Minor"}</p>;
}
// What renders?
Hint
The ternary evaluates the condition and returns one branch.
Explanation
age is 16, which is less than 18, so the ternary returns "Minor". The paragraph renders "Minor".
Related Resources
Related Lessons
- Conditional Rendering
Learn conditional rendering.
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.