I am trying to filter based on multiple values and only if they are not empty. Example:
jobsTracked = [
{
"company": "Company1",
"position": "Senior Frontend Developer",
"role": "Frontend",
"level": "Senior",
},
{
"company": "Company2",
"position": "Senior Frontend Developer",
"role": "Frontend",
"level": "Senior",
}]
I am trying to filter by 3 values in this example: position, role, level. And if position is empty string then i dont want to filter it but still want to filter by role and level if they arent empty string. And vice versa for all of them. Can the JavaScript filter function do this?
filtermethod enables any filter task. It is on the OP to precisely describe the requirements/condition according to which the filter task is going to be performed. Thus as for the mentioned three criteria/property values, does the OP, for each item, want to have every criteria (AND filter) being fulfilled (with the exception of the empty string) or at least one (OR filter)?