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) => {
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 course = 'Half Stack application development'
const part1 = 'Fundamentals of React'
const exercises1 = 10
const part2 = 'Using props to pass data'
const exercises2 = 7
const part3 = 'State of a component'
const exercises3 = 14
const sections = [
{
part: part1,
exerciseCount: exercises1
},
{
part: part2,
exerciseCount: exercises2
},
{
part: part3,
exerciseCount: exercises3
},
]
const course = {
name: 'Half Stack application development',
sections: [
{
part: 'Fundamentals of React',
exerciseCount: 10
},
{
part: 'Using props to pass data',
exerciseCount: 7
},
{
part: 'State of a component',
exerciseCount: 14
},
]
}
return (
<div>
<Header course={course}/>
<Content sections={sections}/>
<Total totalExerciseCount={exercises1 + exercises2 + exercises3}/>
<Header course={course.name}/>
<Content sections={course.sections}/>
<Total sections={course.sections}/>
</div>
)
}

View file

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