I am retrieving a certain document from the collection products and I wanted to compare it to another collection of categories
Specific document from Product collection:
Category collection:
There might be some documents that does not have options, they could be determined by the field value. If it has a string yes, then it does have options. Otherwise, it will be a no.
I can already display the specific document from the product collection. I used map to display the products.
Inside that map, I wanted to have a conditional statement that will display all of the options if the current product's category matches with any of the document in the collection categories that has options in it.
For example, the current product is Shirt with a category of S-L. In the category collection, the S-L does have options.
And if the current product does not have any options, then it will just display "No options"
What I did:
{product &&
product.map((prod, index) => (
<li>{prod.cat}</li>
<li>{prod.prodName}</li>
//if the current product matches with any of the document in the collection category, then show the options, else show "no options"
{category &&
category.map((c, index) => (
<>
<li>{c.cat}</li>
{c.cat === prod.cat ? <>1</> : <>2</>}
</>
))}
))}
How can I do this?