4 lines
233 B
JavaScript
4 lines
233 B
JavaScript
export const filterBySearchTerm = (data = [], searchTerm = '', filterByKey = 'name') => {
|
|
if (!searchTerm?.length) return data;
|
|
return data.filter((item) => item[filterByKey].toLowerCase().includes(searchTerm.toLowerCase()));
|
|
};
|