Trying to get an object whose source value is Kitchen and whose invoice files length equal to zero.
I'm using the filter method but it's not returning any value .im not sure why filter method not returns any value .
could someone help here to move forward
Thanks in advance
var data = [{
"data_id": "1",
"name": "abc",
"source":"Hall",
"sqft": "1100",
"invoiceItems":[
{
"inv_id": "1",
"price": "925",
"Files":[
{
"filename": "a",
"filepath":"zxc"
}]
},
{
"inv_id": "2",
"price": "925",
"source":"tymetrix",
"Files":[]
}
]
}, {
"data_id": "2",
"name": "def",
"source":"Kitchen",
"sqft": "1200",
"invoiceItems":[{
"inv_id": "10",
"price": "925",
"Files":[]
},
{
"inv_id": "11",
"price": "925",
"Files":[
{
"filename": "a",
"filepath":"zxc"
}]
}]
}
];
//console.log(data)
var result = data.filter(function (el) {
if(el.source == "Kitchen"){
console.log(el.invoiceItems)
el.invoiceItems.filter(function(inv){
console.log(inv.Files);
if(inv.Files.length == 0)
{
return true;
}
});
}
});
console.log("result",result)