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
}
];
//Find the todo with the item of Go see Black Panther.
var item;
for (var i = 0; i < todos.length; i++) {
if (todos[i] === 'Go see Black Panther') {
item = todos[i];
break;
}
}
//or Array.find()
var item = todos.find(function (todo) {
return todo.item === 'Go see Black Panther';
});
Also in JavaScript:
- how to print to screen in javascript
- cmv wab widgets
- javascript array add end
- javascript switch items in array
- on focused text input style react native
- how to get the status of other urls in ajax
- javascript for group object properties based on another property
- libraries like html-react-parser
- javascript is int in array
- javascript check if elements of one array are in another
- string methods javascript
- javascript clear file input
- how to update kali linux on virtualbox
- viewdata array mvc razor javascript
- js background image
- array reduce
- javascript foreach syntax
- how to show multiple image preview in jquery
- hoverintent.min.js wordpress error
- generator in classs js
- electron remove default menu
- javascript hover event
- react native function
- add 1 year to current date javascript