so I want to create a filter that returns data based upon the link, if the link contains /rome/ it will list all the pages that contains /rome/ which I've managed to do. But I'm also trying to create a filter based on the market within the cities, for example if the link contains /rome/supermarket/ I want to filter out the pages to return only the pages that contain the city and the market meaning id 1 and 2 in my last link example.

First I'm thinking that I need to loop all over the pages, which are 3 in my example and then loop over again for each city to check if it contains that city and the supermarket and based upon that return the filtered data. I've tried a couple of things but I'm scratching my head here.

```
 pages: [
    {
      id: 1,
      name: 'Meals',
      startDate: '2022-11-09 10:32:00',
      endDate: '2022-11-16 10:32:00',
      cities: {
        rome: ['supermarket'],
      },
    },
    {
      id: 2,
      name: 'Deals',
      startDate: '2022-11-24 11:01:00',
      endDate: '2022-12-01 11:01:00',
      cities: {
        napoli: ['supermarket', 'minimarket'],
        rome: ['supermarket'],
      },
    },
    {
      id: 3,
      name: 'Toys',
      startDate: '2022-11-24 11:01:00',
      endDate: '2022-12-01 11:01:00',
      cities: {
        rome: ['minimarket'],
        venice: ['supermarket', 'minimarket'],
      },
    }
]

```

The filter for the city ->

```
      const pagesFilterCity = pages.filter((item) => {
        return item.cities.hasOwnProperty(city); // where city is 'rome'
      });

```

What I've tried ->

```
      const pagesFilterMarket = pages.filter((item) => {
        return Object.values(item.cities)
          .flat()
          .some((item) => item === market); // where market is 'supermarket'
      });

```

But this will only loop through the first instance from each cities, meaning 3 times

Wanted result: after having /rome/supermarket in the link I want to create a filter that should return the following data from the pages example from above ->
**Note that extracting the data from the link I've already done and that's not my question**

```
 pages: [
    {
      id: 1,
      name: 'Meals',
      startDate: '2022-11-09 10:32:00',
      endDate: '2022-11-16 10:32:00',
      cities: {
        rome: ['supermarket'],
      },
    },
    {
      id: 2,
      name: 'Deals',
      startDate: '2022-11-24 11:01:00',
      endDate: '2022-12-01 11:01:00',
      cities: {
        napoli: ['supermarket', 'minimarket'],
        rome: ['supermarket'],
      },
    }
] // wanted result

```