Predict Default Prop Value
Predict Output Easy
Question
What renders when no size prop is passed?
Code
function Button({ label, size = "medium" }) {
return <button className={size}>{label}</button>;
}
<Button label="Click me" />
Hint
Default parameter values apply when the argument is undefined.
Explanation
No size prop is passed, so the default value "medium" is used. The button has className="medium" and text "Click me".
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.