List Map Render
Predict Output Easy
Question
What does this code print?
Code
function App() {
const items = ["a", "b", "c"];
return <ul>{items.map((x, i) => <li key={i}>{x}</li>)}</ul>;
}
// How many li?
Hint
map creates one li per item.
Explanation
The array has 3 items. map creates 3 <li> elements, one for each item. The key prop uses the index. Three list items render.
Related Resources
Related Lessons
- List Rendering
Learn list rendering.
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.