I want to use filter1 and filter2 functions in generalFilter but I can't comprehend the right syntax to do it in Javascript.
const filter1 = (
array
) => {
return array.filter((parameter, index) => {
return (
!parameter.isOptional()
);
});
};
const filter2 = (
array
) => {
return array.filter((parameter, index) => {
return (
!parameter.isEmpty()
);
});
};
const filterGeneral = (
array
) => {
return array.filter(filter1(array) && filter2(array));
};
This is apprx. what I am trying to do but I am not able to manage to succeed, and I didn't like my logic. Is there any way to do this properly?
array.filter(func1).filter(func2)