function Main(){
// create an array that holds objects
const people = [
{
firstName: 'Fathi',
lastName: 'Noor',
age: 27,
colors: ['red', 'blue'],
bodyAttributes: {
weight: 64,
height: 171
}
},
{
firstName: 'Hanafi',
lastName: 'Noor',
age: 26,
colors: ['white', 'black'],
bodyAttributes: {
weight: 62,
height: 172
}
}
]
return(
<main>
<div>
/* display person age equal to 27 using filter using ES6 arrow */
{people.filter(person => person.age == 27)}
</div>
</main>
)
}
我对反应和使用map而不是普通的循环函数很陌生。
当我运行这段代码时,它给了我这个错误(如下所示)
你们能教我在按年龄等于 27过滤时如何显示一个人的所有数据的正确方法吗?