exercise 1.4
This commit is contained in:
parent
2cbd61cb88
commit
bbcea9fd36
|
@ -7,10 +7,11 @@ const Header = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Part = (props) => {
|
const Part = (props) => {
|
||||||
|
console.log(props)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
{props.part} {props.exercise}
|
{props.part.name} {props.part.exercises}
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -19,18 +20,19 @@ const Part = (props) => {
|
||||||
const Content = (props) => {
|
const Content = (props) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Part part={props.part1} exercise={props.exercises1} />
|
<Part part={props.parts[0]} />
|
||||||
<Part part={props.part2} exercise={props.exercises2} />
|
<Part part={props.parts[1]} />
|
||||||
<Part part={props.part3} exercise={props.exercises3} />
|
<Part part={props.parts[2]} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Total = (props) => {
|
const Total = (props) => {
|
||||||
|
const total = props.parts[0].exercises + props.parts[1].exercises + props.parts[2].exercises
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
Number of exercises {props.total}
|
Number of exercises {total}
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -38,19 +40,25 @@ const Total = (props) => {
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const course = 'Half Stack application development'
|
const course = 'Half Stack application development'
|
||||||
const part1 = 'Fundamentals of React'
|
const part1 = {
|
||||||
const exercises1 = 10
|
name: 'Fundamentals of React',
|
||||||
const part2 = 'Using props to pass data'
|
exercises: 10
|
||||||
const exercises2 = 7
|
}
|
||||||
const part3 = 'State of a component'
|
const part2 = {
|
||||||
const exercises3 = 14
|
name: 'Using props to pass data',
|
||||||
const total = exercises3 + exercises2 + exercises1
|
exercises: 7
|
||||||
|
}
|
||||||
|
const part3 = {
|
||||||
|
name: 'State of a component',
|
||||||
|
exercises: 14
|
||||||
|
}
|
||||||
|
const parts = [part1, part2, part3]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Header course={course} />
|
<Header course={course} />
|
||||||
<Content part1={part1} part2={part2} part3={part3} exercises1={exercises1} exercises2={exercises2} exercises3={exercises3} />
|
<Content parts={parts} />
|
||||||
<Total total={total} />
|
<Total parts={parts} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue