find the matching property code example
Example: find the matching property
var todos = [
{
item: 'Wash the dog',
added: 2018-03-22,
completed: false
},
{
item: 'Plan surprise party for Bailey',
added: 2018-03-14,
completed: false
},
{
item: 'Go see Black Panther',
added: 2018-03-12,
completed: true
},
{
item: 'Launch a podcast',
added: 2018-03-05,
completed: false
}
];
var item;
for (var i = 0; i < todos.length; i++) {
if (todos[i] === 'Go see Black Panther') {
item = todos[i];
break;
}
}
var item = todos.find(function (todo) {
return todo.item === 'Go see Black Panther';
});