Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array filter with multiple conditions

var conditions = [];

 // Dynamically build the list of conditions
 if(startDateFilter) {
    conditions.push(function(item) { 
       return item.transdate >= startDateFilter.startDate;
    });
 };

 if(categoryFilter) {
     conditions.push(function(item) {
         return item.cateogry === categoryFilter.category;
     });
 };
 // etc etc
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #array #filter #multiple #conditions
ADD COMMENT
Topic
Name
4+1 =