How to find selected array item in another array?

Hi, I need some help with JavaScript logic here.

  1. I have an Observable array which is filled by a fetch request (products)
  2. 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:
id_product: …

@albertolopezdev I think you’re thinking of the where condition or flatMap: