I have an array and an object. In the array I have a list of Products and in the object I have a category.
What I should to do is to find a code in the array equals to the category.Code .
So I have thought to do a .map of the array, but I don't know how to return back only the values equal to category.code.
console.log("this.props.products: ", this.props.products)
console.log("this.props.category: ", this.props.category)
let findProducts = this.props.products.Products.map((product) => {
console.log("product_", product.Categories.MainCode)
product.Categories.MainCode == this.props.category.Code
})
console.log("findProducts: ", findProducts)
The findProducts returns me a list of undefined.
Basically I want obtain only the this.props.products.Products.Categories.MainCode == this.props.category.Code
(that should be more than one).
How can I do?? Thank you