This is a simplified example of a problem I have on a website.
I have an array with some items like this:
var testArr = ["Jeremy", "John", "Hank", "Hal"];
If I know what the filters are, I can filter it like this:
var testArr2 = testArr.filter(function (item){
return item.length < 5 &&
item.startsWith("H");
});
On my website, I have an interface where the user can select several filters. In this example, the user would be able to decide to filter by either length or what the value starts with. I need to be able to add conditions to that return
dynamically or find some other way to filter. I tried some of the answers at he SO thread javascript filter array multiple conditions, but I am having trouble applying that to my example.
Thanks in advance!