I have a collection initialized like this:
var invoices = new Array();
var invoice = new Invoice();
invoice.number = "123";
invoice.date = "2016-05-03";
invoice.amount = "100";
var products = new Products();
var product = new Product();
product.code = "A";
product.name = "bar";
products.push(product);
var product2 = new Product();
product2.code = "B";
product2.name = "foo";
products.push(product2);
invoice.products = products;
Now I got to filter by the properties of the invoice like this.
var filtered = invoices.filter(function(invoice){
return invoice.number == "123";
});
But now I want to get the invoice that matches with number and the product name
How can I do this
var filtered = invoices.filter(function(invoice){
return invoice.number == "123"
// && invoice.products "name" == "foo"; //<-- At this level how can I filter?
});