diff --git a/part2/src/App.js b/part2/src/App.js index 54b6632..e97353f 100644 --- a/part2/src/App.js +++ b/part2/src/App.js @@ -1,40 +1,4 @@ -const Header = ({ content }) => { - return (

{content}

) -} - -const Content = ({ parts }) => { - return ( - <> - {parts.map(part => -

- {part.name} Exercises {part.exercises} -

) - } - - ) -} - -const Sum = ({ parts }) => { - const total = parts.reduce((acc, currVal) => acc + currVal.exercises, 0) - return ( - The total number of execrcises is {total} - ) -} - -const Course = ({ courses }) => { - return ( - <> - {courses.map(course => - <> -
- - - - )} - - ) - -} +import Course from './components/Course' function App() { const courses = [ diff --git a/part2/src/components/Content.js b/part2/src/components/Content.js new file mode 100644 index 0000000..dbc3d0e --- /dev/null +++ b/part2/src/components/Content.js @@ -0,0 +1,14 @@ +const Content = ({ parts }) => { + return ( + <> + {parts.map(part => +

+ {part.name} Exercises {part.exercises} +

) + } + + ) +} + + +export default Content; diff --git a/part2/src/components/Course.js b/part2/src/components/Course.js new file mode 100644 index 0000000..99914cf --- /dev/null +++ b/part2/src/components/Course.js @@ -0,0 +1,19 @@ +import Content from './Content' +import Header from './Header' +import Sum from './Sum' + +const Course = ({ courses }) => { + return ( + <> + {courses.map(course => + <> +
+ + + + )} + + ) +} + +export default Course; diff --git a/part2/src/components/Header.js b/part2/src/components/Header.js new file mode 100644 index 0000000..9616233 --- /dev/null +++ b/part2/src/components/Header.js @@ -0,0 +1,5 @@ +const Header = ({ content }) => { + return (

{content}

) +} + +export default Header; diff --git a/part2/src/components/Sum.js b/part2/src/components/Sum.js new file mode 100644 index 0000000..87d103e --- /dev/null +++ b/part2/src/components/Sum.js @@ -0,0 +1,8 @@ +const Sum = ({ parts }) => { + const total = parts.reduce((acc, currVal) => acc + currVal.exercises, 0) + return ( + The total number of execrcises is {total} + ) +} + +export default Sum;