completed exercises up to 1.5
This commit is contained in:
parent
3bcd98dd10
commit
af60797cb7
2 changed files with 32 additions and 32 deletions
|
|
@ -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
|
|
||||||
const part3 = 'State of a component'
|
|
||||||
const exercises3 = 14
|
|
||||||
|
|
||||||
const sections = [
|
|
||||||
{
|
{
|
||||||
part: part1,
|
part: 'Fundamentals of React',
|
||||||
exerciseCount: exercises1
|
exerciseCount: 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
part: part2,
|
part: 'Using props to pass data',
|
||||||
exerciseCount: exercises2
|
exerciseCount: 7
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
part: part3,
|
part: 'State of a component',
|
||||||
exerciseCount: exercises3
|
exerciseCount: 14
|
||||||
},
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
|
||||||
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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue