I have an array as:
var arr =
[
{
"id":3,
"first_name":"Laila",
"last_name":"McCaine",
"gender":"female",
"populations":[{"population_name":"Heart failure"}, {"population_name":"AMI"}],
"score": 55.0
},
{
"id":5,
"first_name":"Riva",
"last_name":"Rontgen",
"gender":"female",
"populations":[{"population_name":"Pnumonia"}],
"score": 85.0
},
{
"id":8,
"first_name":"Emily",
"last_name":"Rosewood",
"gender":"female",
"populations":[],
"score": 25.0
}
];
and variables :
var score='';
var population='';
var status = '';
I want to use array filter function with and conditions such as
Get records having score less than 40, status = 1 and population_name as "heart failure".
The problem is, given 3 variables are dynamic and filter should not be applied if its value is ''.
How can I achieve this?
""; what have you tried?