Recap: Conditions & Lists
Part of the Fundamentals section of Coddy's React journey — lesson 38 of 42.
Challenge
MediumChapter recap: build a task board from the data, using everything from this chapter.
- The component defines a
tasksarray. Inside the<ul id="done-list">, render one<li>per task that is done:filterfirst, thenmap. - Each
<li>shows the task'stextand uses itsidas thekey. - Above the list, use
&&to render a<span>withid="badge"reading2 done(build the number from the filtered array'slength!), but only when at least one task is done.
Try it yourself
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="root"></div>
<script type="module" src="main.jsx"></script>
</body>
</html>All lessons in Fundamentals
7Conditions & Lists
Ternary RenderingShow with &&Render a ListKeys MatterFilter, Then MapRecap: Conditions & Lists2JSX Expressions
Curly BracesMath in BracesBraces in AttributesCalling Functions in JSXRecap: JSX Expressions5State & Events
What Is State?Click CounterCount in StepsToggle with StateIndependent StateRecap: State & Events8Project: Profile Card
Step 1: Card StructureStep 2: Card with PropsStep 3: Like ButtonStep 4: Follow Toggle