From 269ab61b887718ac5820b7f50cd9de3682944a5d Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Sun, 23 Apr 2023 19:49:10 -0400 Subject: ex 1.5 --- part1/courseinfo/src/App.js | 53 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/part1/courseinfo/src/App.js b/part1/courseinfo/src/App.js index a500c35..ad43367 100644 --- a/part1/courseinfo/src/App.js +++ b/part1/courseinfo/src/App.js @@ -1,13 +1,14 @@ const Header = (props) => { + const header = props.parts.name return ( -

{props.name}

+

{header}

) } const Content = (props) => { - const object_1 = props.parts[0] - const object_2 = props.parts[1] - const object_3 = props.parts[2] + const object_1 = props.parts.parts[0] + const object_2 = props.parts.parts[1] + const object_3 = props.parts.parts[2] return (

@@ -21,9 +22,9 @@ const Content = (props) => { } const Total = (props) => { - const one = props.parts[0].exercises - const two = props.parts[1].exercises - const three = props.parts[2].exercises + const one = props.parts.parts[0].exercises + const two = props.parts.parts[1].exercises + const three = props.parts.parts[2].exercises return (

Number of exercises {one + two + three}

@@ -31,27 +32,29 @@ const Total = (props) => { } const App = () => { - const course = 'Half Stack application development' - const parts = [ - { - name: 'Fundamentals of React', - exercises: 10 - }, - { - name: 'Using props to pass data', - exercises: 7 - }, - { - name: 'State of a component', - exercises: 14 - } - ] + const course = { + name: 'Half Stack application development', + parts: [ + { + name: 'Fundamentals of React', + exercises: 10 + }, + { + name: 'Using props to pass data', + exercises: 7 + }, + { + name: 'State of a component', + exercises: 14 + } + ] + } return (
-
- - +
+ +
) } -- cgit v1.2.3