I'm trying to do a .filter() method on each keyup to get back a list of objects in the following array that match the value of an input field:
var peopleArray = [
{
name: "Steve",
email: "[email protected]"
},
{
name: "Sam",
email: "[email protected]"
},
{
name: "Sarah",
email: "[email protected]"
},
{
name: "Kyle",
email: "[email protected]"
},
{
name: "Kody",
email: "[email protected]"
},
{
name: "Scarlet",
email: "[email protected]"
},
]
Here is what I'm using to search:
<input type="search" id="searchInput" placeholder="Search Activities" />
searchInput.addEventListener('keyup', function() {
searchPeople(searchInput.value);
})
function searchPeople(chars) {
//Search People and return a list of JSON objects
return //All JSON objects that matched
}
I'm new to this so I don't quite understand how to achieve this.
charsare included inname?