Hi, I need some help with JavaScript logic here.
- I have an Observable array which is filled by a fetch request (products)
- From array “products”, I can select an item and add it to array “cart”
When i’m adding items from array “products” to array “cart”, how can I check if the “product” has already been added to array “cart”? This to avoid duplicates.
*Both share the key id_product and both are Observable arrays.
** The way I’m adding the product is with:
cart.add({
id_product: …
})