Predict && Rendering
Predict Output Easy
Question
What renders in the browser?
Code
const hasError = true;
const ui = <div>{hasError && <span>Error occurred</span>}</div>;
Hint
When the left side is true, && returns the right side.
Explanation
Since hasError is true, && returns the right side: <span>Error occurred</span>. The rendered text is "Error occurred" inside the <div>.
Related Resources
Related Lessons
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.