.map() elements code example
Example 1: map function in react
function NameList() {
const names = ['Bruce', 'Clark', 'Diana']
return (
<div>
{names.map(name => <h2>{name}</h2>)}
</div>
)
}
Example 2: javascript map
The map() method creates a new array with the results of calling a provided function on every element in the calling array.