I have an array of objects. i want to filter array based the object has the condition.
my array is as follow :
var data = [
{
"name": "nitin",
"r_id": "1",
"t_id": "4"
},
{
"name": "test",
"r_id": "2",
"t_id": "3"
},
{
"name": "test1",
"r_id": "2",
"t_id": "4"
},
{
"name": "test3",
"r_id": "3",
"t_id": "3"
},
{
"name": "test2",
"r_id": "1",
"t_id": "1"
}]
and my object is as follows :
var obj = {
role:['1','2'],
type:['1','3']
}
where r_id is the role id and t_id is the type id
so i want the results whose role id is in 1 or 2 AND type id is in 1 or 3.
so mathematically role_id && type_id ((1||2)&&(1||3))
my output should like:
var result = [
{
'name':'test',
'r_id':2,
't_id':3,
},
{
'name':'test2',
'r_id':1,
't_id':1,
}];