I have the below Array of object set, I need to take the some of them based on the condition from the whole array set using lodash.
I have used _.filter(data, condition) in lodash, but expected result is not coming.
Anyone help me to resolve this ?
Condition : EarnCode < 90 && Hours === 0 (result will be skipped those data).
Request Array set:
[
{
"id" : 1,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 96,
"Hours" : 0
},
{
"id" : 3,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 96,
"Hours" : 0
},
{
"id" : 2,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 1,
"Hours" : 0
},
{
"id" : 5,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 1,
"Hours" : 3
}
]
Expected Result:
[
{
"id" : 1,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 96,
"Hours" : 0
},
{
"id" : 3,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 96,
"Hours" : 0
},
{
"id" : 5,
"EmpId" : 100,
"AcctCode" : "2001-00",
"SuperID" : 2000,
"ReportNo" : "20180213.2015-06.2768.6",
"EarnCode" : 1,
"Hours" : 3
}
]
EarnCode >= 90 || Hours !== 0rejectinstead offilterwith your condition