Is it possible to filter for those objects, which matches for a search string?
const arr = [
{ title: 'Just an example' },
{ title: 'Another exam'},
{ title: 'Something different'}
]
I tried this
arr.filter(x => { return x.title === searchStr });
But this will filter only exact matches, but I need to find all partial matches. let searchStr = 'exam' should give me two objects (first and second), let searchStr = 'examp' should give me only one object as the result.
x.title.indexOf(searchStr) !== -1?