I need to get results from firstname or lastname,
current behaviour gives me results from firstname only. Or a better approach to this using filter() :) should not be case sensitive too
const people = [
{ firstName: 'Bob', lastName: 'Smith', status: 'single' },
{ firstName: 'bobby', lastName: 'Suxatcapitalizing', status: 'single' },
{ firstName: 'Jim', lastName: 'bob', status: 'complicated' },
]
const searchString = 'bob'
const found = people.filter(
(person) => new RegExp(searchString, 'i')
.test(
person.firstName || person.lastName
))
console.log(found)