Skip to content
Advertisement

Filter in array of object inside object in Javascript

I’m trying to filter some products with the categories (by the woocommerce API) but i have a little trouble to do it. do you have the right way to do it? thanks

My array from the API :

JavaScript

And my filter function:

JavaScript

Advertisement

Answer

Here’s what you want, I reckon. A filter that checks whether any of the categories of the product has the id you’re looking for.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement