Render one list item per name.
Acceptance criteria
- 1.#root li should show 3 items.
React Tutorial · Lists and Keys
These 10 tasks go with the Rendering Lists chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Rendering a list is map . There is no loop syntax in JSX because an array of elements is already something React knows how to render.” Read the chapter.
1.Map an array to elementsexercise · easy · 10 min
Render one list item per name.
Passes when: #root li should show 3 items.
2.Map objectsexercise · easy · 10 min · practice plan
Render a list from objects, showing one field.
Passes when: #root should show Ada.
3.Filter before mappingexercise · easy · 10 min · practice plan
Render only the even numbers.
Passes when: #root li should show 2 items.
4.Show an empty stateexercise · easy · 10 min · practice plan
Render a message when the list has nothing in it.
Passes when: #value should show Nothing here.
5.Render a list of componentsexercise · medium · 10 min · practice plan
Map to a component rather than a plain element.
Passes when: #root .row should show 2 rows.
6.Fix forEach used instead of mapbug fix · easy · 8 min
forEach returns nothing, so no elements come back.
Passes when: The list should hold three items.
7.Fix the map with no returnbug fix · easy · 8 min · practice plan
Braces after the arrow make a body, so nothing is returned.
Passes when: The list should hold two items.
8.Fix the filter that keeps nothingbug fix · easy · 8 min · practice plan
The predicate is inverted, so the list comes out empty.
Passes when: Only the even numbers should be listed.
9.Fix the object rendered directlybug fix · easy · 8 min · practice plan
Render a field of the object, not the object itself.
Passes when: The item should show Ada.
10.Fix the missing empty statebug fix · medium · 8 min · practice plan
An empty list renders nothing at all; show a message.
Passes when: #root should show Nothing here.
Between them these tasks cover map, filter and Empty states.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.