completed exercises up to 1.5

This commit is contained in:
counterweight 2025-05-18 20:03:55 +02:00
parent 3bcd98dd10
commit af60797cb7
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 32 additions and 32 deletions

View file

@ -20,42 +20,42 @@ const Content = (props) => {
const Total = (props) => { const Total = (props) => {
return ( return (
<> <>
<p>Number of exercises {props.totalExerciseCount}</p> <p>Number of exercises {props.sections.reduce(
(sum, section) => {
return sum + section.exerciseCount
},
0
)}</p>
</> </>
) )
} }
const App = () => { const App = () => {
const course = 'Half Stack application development' const course = {
const part1 = 'Fundamentals of React' name: 'Half Stack application development',
const exercises1 = 10 sections: [
const part2 = 'Using props to pass data' {
const exercises2 = 7 part: 'Fundamentals of React',
const part3 = 'State of a component' exerciseCount: 10
const exercises3 = 14 },
{
part: 'Using props to pass data',
exerciseCount: 7
},
{
part: 'State of a component',
exerciseCount: 14
},
const sections = [ ]
{ }
part: part1,
exerciseCount: exercises1
},
{
part: part2,
exerciseCount: exercises2
},
{
part: part3,
exerciseCount: exercises3
},
]
return ( return (
<div> <div>
<Header course={course}/> <Header course={course.name}/>
<Content sections={sections}/> <Content sections={course.sections}/>
<Total totalExerciseCount={exercises1 + exercises2 + exercises3}/> <Total sections={course.sections}/>
</div> </div>
) )
} }

View file

@ -2,9 +2,9 @@ How to start a react app:
`npm create vite@latest <your apps name here> -- --template react` `npm create vite@latest <your apps name here> -- --template react`
Exercises: Exercises:
* [ ] 1.1 * [X] 1.1
* [ ] 1.2 * [X] 1.2
* [ ] 1.3 * [X] 1.3
* [ ] 1.4 * [X] 1.4
* [ ] 1.5 * [X] 1.5