Learn Basic OOP by Building a Shopping Cart - Step 24

Tell us what’s happening:

I am using parenthesis but still this issue is happening again and again. the error states to put the parenthesis.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

  addItem(id, products) {
    const product = products.find((item) => item.id === id);
    const { name, price } = product;
    this.items.push(product);

    const totalCountPerProduct = {};
    this.items.forEach((dessert) => {
    totalCountPerProduct[dessert.id] = (totalCountPerProduct[dessert.id]) + 1||0;
    })
  }

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 24

This is the statement that you needed to add || 0 to (so move it here)

1 Like