Complete the code to pass a prop named name with value "Alice" to the Greeting component.
function App() {
return <Greeting [1] />;
}Props are like attributes you add to components. Here, name="Alice" passes the value "Alice" as a prop called name.
Complete the code to access the name prop inside the Greeting component.
function Greeting([1]) { return <h1>Hello, {name}!</h1>; }
Using {name} in the function parameter extracts the name prop directly for easy use.
Fix the error in the code to correctly display the name prop.
function Greeting(props) {
return <h1>Hello, [1]!</h1>;
}When using props as a parameter, access the name prop with props.name.
Fill both blanks to pass two props firstName and age to the User component.
function App() {
return <User [1] [2] />;
}Props are passed as attributes. Here, firstName="Bob" and age={30} pass two props correctly.
Fill all three blanks to create a Profile component that receives props and displays them.
function Profile([1], [2], [3]) { return ( <div> <h2>{firstName} {lastName}</h2> <p>Age: {age}</p> </div> ); }
The component destructures the props firstName, lastName, and age to use them inside.