5 lines
233 B
JavaScript
5 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()));
|
||
|
};
|