Build a Shopping Cart - Step 42

Tell us what’s happening:

I don’t know how to do what the test keeps telling me to do:
You should assign the value of your cart object’s .getCounts() method to the textContent property of the totalNumberOfItems variable.
Please help.

Your code so far

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

/* file: styles.css */

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

[...addToCartBtns].forEach(
  (btn) => {
    btn.addEventListener("click", (event) => {
      cart.addItem(Number(event.target.id), products);
      cart.getCounts() = totalNumberOfItems.textContent
    })
  }
);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Challenge Information:

Build a Shopping Cart - Step 42

Here you are assigning totalNumberOfItems.textContent to the cart.getCounts(). This is a syntax error because you cannot assign a value to a function call.

What is the value of the cart object’s .getCounts() method then?

Does the instructions ask for you to

  1. assign totalNumberOfItems.textContent to cart.getCounts()

or

  1. assign cart.getCounts() to totalNumberOfItems.textContent
1 Like

Oh! I needed to flip around the two things I was comparing using the = sign. Thank you!

1 Like