1.Profile card with props
BeginnerWrite a ProfileCard component that takes name, role and an optional location (default "Remote"), and render two cards: Neha, Designer, Bengaluru; and Arjun, Developer, with no location.
Show hint
Destructure the props with a default value, function ProfileCard({ name, role, location = "Remote" }).
Show solution
function ProfileCard({ name, role, location = "Remote" }) {
return (
<div style={{ border: "1px solid #ddd", borderRadius: 8, padding: 10, marginBottom: 8 }}>
<strong>{name}</strong>
<div>{role} · {location}</div>
</div>
);
}
export default function App() {
return (
<div>
<ProfileCard name="Neha" role="Designer" location="Bengaluru" />
<ProfileCard name="Arjun" role="Developer" />
</div>
);
}Props arrive as one object; destructuring with = "Remote" supplies the value when the prop is not passed.