Recall & Review
beginner
What is JSX in React?
JSX is a syntax that looks like HTML but is used in React to describe the UI structure. It lets you write HTML-like code inside JavaScript.
Click to reveal answer
beginner
How do you embed a JavaScript expression inside JSX?
You embed JavaScript expressions inside JSX by wrapping them in curly braces {}.
Click to reveal answer
intermediate
Can you embed statements like if or for loops directly inside JSX?
No, you cannot embed statements like if or for loops directly inside JSX. You can use expressions like ternary operators or call functions that return JSX instead.
Click to reveal answer
intermediate
What happens if you embed a JavaScript expression that returns null or false in JSX?
If a JavaScript expression returns null or false inside JSX, React will render nothing for that part. This is useful for conditional rendering.
Click to reveal answer
beginner
Example: What will this JSX render?
{`{2 + 3}
`}It will render an <h1> element with the number 5 inside because the expression 2 + 3 is evaluated to 5.
Click to reveal answer
How do you insert a JavaScript variable named 'name' inside JSX?
✗ Incorrect
You use curly braces {} to embed JavaScript expressions inside JSX, so {name} inserts the variable's value.
Which of these can you NOT directly put inside JSX curly braces?
✗ Incorrect
JSX curly braces accept expressions, but statements like if cannot be used directly. Use ternary or functions instead.
What will React render if the expression inside JSX returns false?
✗ Incorrect
React treats false, null, and undefined as nothing and renders no output for those expressions.
Which syntax correctly embeds the result of 10 * 2 inside a paragraph in JSX?
✗ Incorrect
Curly braces {} are used to embed JavaScript expressions inside JSX elements.
To conditionally render 'Hello' or 'Goodbye' inside JSX, which is correct?
✗ Incorrect
Ternary operator inside curly braces is the correct way to conditionally render in JSX.
Explain how to embed JavaScript expressions inside JSX and why curly braces are used.
Think about how you mix JavaScript and HTML-like code in React.
You got /3 concepts.
Describe how to conditionally render content inside JSX without using if statements directly.
Remember JSX only accepts expressions, not statements.
You got /3 concepts.