Let's assume I have a store with different orders. The orders have a delivery address and an invoice address. The address itself has a city, street etc.:
let data = [
{ id: 1, name: 'Anna', delivery: {city: "Amsterdam"}, invoice: {city: "Amsterdam"} },
{ id: 2, name: 'Anton', delivery: {city: "Amsterdam"}, invoice: {city: "Berlin"}}
];
I would like to filter all orders where the city of both the delivery address and the invoice address is the same.
I have tried that in a jsFiddle: https://jsfiddle.net/gbwv2bde/3/, but I am not so happy with the results. Does anybody know a way to use a Filter for that task?
Try this, it will return items Anna and Julie
Basically you can create a your own functions to pass to filter(), which you can use to write your own comparison logic.
See here for more details https://github.com/SitePen/dstore/blob/master/docs/Collection.md
EDIT: Example with more properties to compare. Your function just needs to return a true or false (true if the object matches your comparison conditions)