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