I'm new to React and programing in general and I'm having trouble writing code that return each element in an array, in React JS. the whole code is below:
import React from 'react'
const App = () => {
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
}
]
}
const Header = (props) => {
return (
<h1>{props.course.name}</h1>
)
}
const Content = (props) => {
const lisItem = props.course.parts.map((part =>
<li>{props.course.parts.name}</li>
))
return (
<ul>{lisItem}</ul>
)
}
return (
<div>
<Header course={course}/>
<Content course={course}/>
</div>
)
}
export default App
Right now it half-works: I can display 3 bullet points (match with numbers of parts) but cannot display the name of the part itself.
Also I would like to clarify the out put a wanted is the course's name and each name of the parts be displayed.
Any help would be appreciated. Thank you very much.