Exercise 1.4

This commit is contained in:
Augusto Gunsch 2022-06-12 11:51:44 +02:00
parent 5b11be3a96
commit 565f86e6fd
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 20 additions and 18 deletions

View File

@ -8,36 +8,38 @@ const Part = (props) => (
const Content = (props) => (
<div>
<Part part={props.part1.name} exercise={props.part1.exercises} />
<Part part={props.part2.name} exercise={props.part2.exercises} />
<Part part={props.part3.name} exercise={props.part3.exercises} />
<Part part={props.parts[0].name} exercise={props.parts[0].exercises} />
<Part part={props.parts[1].name} exercise={props.parts[1].exercises} />
<Part part={props.parts[2].name} exercise={props.parts[2].exercises} />
</div>
)
const Total = (props) => (
<p>Number of exercises {props.total}</p>
<p>Number of exercises {props.parts[0].exercises + props.parts[1].exercises + props.parts[2].exercises}</p>
)
const App = () => {
const course = 'Half Stack application development'
const part1 = {
name: 'Fundamentals of React',
exercises: 10
}
const part2 = {
name: 'Using props to pass data',
exercises: 7
}
const part3 = {
name: 'State of a component',
exercises: 14
}
const parts = [
{
name: 'Fundamentals of React',
exercises: 10
},
{
name: 'Using props to pass data',
exercises: 7
},
{
name: 'State of a component',
exercises: 14
}
]
return (
<div>
<Header course={course} />
<Content part1={part1} part2={part2} part3={part3}/>
<Total total={part1.exercises + part2.exercises + part3.exercises} />
<Content parts={parts}/>
<Total total={parts} />
</div>
)
}