completed exercise 1.1

This commit is contained in:
counterweight 2025-05-18 19:46:45 +02:00
parent b11136fc9d
commit c118246961
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
12 changed files with 2778 additions and 2 deletions

View file

@ -0,0 +1,58 @@
const Header = (props) => {
return <h1>{props.course}</h1>
}
const Content = (props) => {
return (
<>
{props.sections.map((section) => {
return <p>{section.part} {section.exerciseCount}</p>
})}
</>
)
}
const Total = (props) => {
return (
<>
<p>Number of exercises {props.totalExerciseCount}</p>
</>
)
}
const App = () => {
const course = 'Half Stack application development'
const part1 = 'Fundamentals of React'
const exercises1 = 10
const part2 = 'Using props to pass data'
const exercises2 = 7
const part3 = 'State of a component'
const exercises3 = 14
const sections = [
{
part: part1,
exerciseCount: exercises1
},
{
part: part2,
exerciseCount: exercises2
},
{
part: part3,
exerciseCount: exercises3
},
]
return (
<div>
<Header course={course}/>
<Content sections={sections}/>
<Total totalExerciseCount={exercises1 + exercises2 + exercises3}/>
</div>
)
}
export default App

View file

@ -0,0 +1,5 @@
import ReactDOM from 'react-dom/client'
import App from './App'
ReactDOM.createRoot(document.getElementById('root')).render(<App />)