Challenge - 5 Problems
JSX Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this JSX component?
Consider this React component. What will it render in the browser?
React
function Greeting() { const name = "Alex"; return <h1>Hello, {name}!</h1>; }
Attempts:
2 left
💡 Hint
Remember that JSX expressions inside curly braces are evaluated as JavaScript.
✗ Incorrect
The JSX expression {name} is replaced by the value of the variable name, which is "Alex". So the component renders an h1 element with the text "Hello, Alex!".
📝 Syntax
intermediate2:00remaining
Which JSX snippet is syntactically correct?
Select the JSX code that will compile without syntax errors.
Attempts:
2 left
💡 Hint
JSX requires all tags to be properly closed and nested.
✗ Incorrect
Option B has properly nested and closed tags. Options B and C have missing closing tags, and D has an extra closing tag.
❓ state_output
advanced2:00remaining
What is the rendered output after clicking the button once?
Given this React component, what will be the displayed count after clicking the button once?
React
import React, { useState } from 'react'; function Counter() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); setCount(count + 1); } return ( <div> <p>Count: {count}</p> <button onClick={handleClick}>Increase</button> </div> ); }
Attempts:
2 left
💡 Hint
Remember that React state updates may be batched and asynchronous.
✗ Incorrect
Both setCount calls use the same stale count value (0), so the count only increases by 1 after the click.
🔧 Debug
advanced2:00remaining
Which JSX code causes a syntax error?
Identify the JSX snippet that will cause a syntax error when compiled.
Attempts:
2 left
💡 Hint
Check if all tags are properly nested and closed.
✗ Incorrect
Option A has incorrectly nested tags: the
, which is invalid in JSX.tag is closed after the
🧠 Conceptual
expert2:00remaining
What error does this JSX code produce?
What error will this React component cause when rendered?
React
function List() { const items = ["a", "b", "c"]; return ( <ul> {items.map(item => <li>{item}</li>)} </ul> ); }
Attempts:
2 left
💡 Hint
React requires a special prop when rendering lists to help identify items.
✗ Incorrect
React warns when list items lack a unique key prop to optimize rendering updates.