exercise 1.5

This commit is contained in:
Anish Lakhwara 2023-04-29 14:25:23 +10:00
parent bbcea9fd36
commit 08b2a6caac

View file

@ -1,7 +1,7 @@
const Header = (props) => { const Header = (props) => {
return ( return (
<h1> <h1>
{props.course} {props.course.course}
</h1> </h1>
) )
} }
@ -20,15 +20,15 @@ const Part = (props) => {
const Content = (props) => { const Content = (props) => {
return ( return (
<> <>
<Part part={props.parts[0]} /> <Part part={props.course.parts[0]} />
<Part part={props.parts[1]} /> <Part part={props.course.parts[1]} />
<Part part={props.parts[2]} /> <Part part={props.course.parts[2]} />
</> </>
) )
} }
const Total = (props) => { const Total = (props) => {
const total = props.parts[0].exercises + props.parts[1].exercises + props.parts[2].exercises const total = props.course.parts[0].exercises + props.course.parts[1].exercises + props.course.parts[2].exercises
return ( return (
<> <>
<p> <p>
@ -39,7 +39,7 @@ const Total = (props) => {
} }
const App = () => { const App = () => {
const course = 'Half Stack application development' const title = 'Half Stack application development'
const part1 = { const part1 = {
name: 'Fundamentals of React', name: 'Fundamentals of React',
exercises: 10 exercises: 10
@ -53,12 +53,16 @@ const App = () => {
exercises: 14 exercises: 14
} }
const parts = [part1, part2, part3] const parts = [part1, part2, part3]
const course = {
course: title,
parts: parts
}
return ( return (
<div> <div>
<Header course={course} /> <Header course={course} />
<Content parts={parts} /> <Content course={course} />
<Total parts={parts} /> <Total course={course} />
</div> </div>
) )
} }