const todos = [{
title:'Go to gym',
isdone: true
},{
title: 'Buy bread',
isdone: false
},{
title : 'Do javaScript',
isdone : true
},{
title:'Do home works',
isdone:true
},{
title:'Watch Tutorials',
isdone:false
},{
title:'Take a nap',
isdone:false
}]
我想在isdone == false
的todos数组中打印对象的所有标题。我只能使用filter()
函数吗?
const thingsDone = todos.filter((todos) => todos.isdone === false)
thingsDone.forEach((mytodos) =>{console.log(mytodos.title)})
我使用这些代码行来完成任务。使用filter()
函数有没有更简单的方法?