So i want to use array.filter to values that are not empty string in an object in the following senario
setData(
_.filter(rows, item => {
return (
item.firstName.toLowerCase().includes(filterTable.searchByName.toLowerCase()) &&
item.email.toLowerCase().includes(filterTable.searchByEmail.toLowerCase()) &&
item.cognitoId.toLowerCase().includes(filterTable.searchByCognitoId.toLowerCase()) &&
item.mfaEnabled.toString() === filterTable.searchByMfa.toString()
);
})
);
i can use ifelse to what values are there but that will be a hell of a long ifelse
in the above code i want to add those items in _.filter that's value is !== ''
for example if filterTable.email === '' then i want following
setData(
_.filter(rows, item => {
return (
item.firstName.toLowerCase().includes(filterTable.searchByName.toLowerCase()) &&
item.cognitoId.toLowerCase().includes(filterTable.searchByCognitoId.toLowerCase()) &&
item.mfaEnabled.toString() === filterTable.searchByMfa.toString()
);
})
);