Learn Basic OOP by Building a Shopping Cart - Step 27

Tell us what’s happening:

Can you explain what you are asking for in a different way?

The language of ‘undefined’ for truthy and falsey is confusing me.

I can’t tell if you want me to use a method to check if the object has the product already or if you want me to use some other stylistic convention. Please help.

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] || 0) + 1;
    })

    const currentProductCount = totalCountPerProduct[product.id];
    const currentProductCountSpan = document.getElementById(`product-count-for-id${id}`);
    

  }

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 27

The instructions said to “create a ternary” and use undefined in place of the truthy and falsy parts.

Ternery expression is something like this
condition ? exprIfTrue : exprIfFalse

It’s a shorthand way of writing a conditional statement. If you’ve forgotten it you can google “how to write a js ternary” and should see some examples to jog your memory.

Edit:
P.s. the step also highlighted the word undefined so they literally are asking you to write that word in place of the truthy and falsy parts of the ternary statement.