Learn Basic OOP by Building a Shopping Cart - Step 60

Tell us what’s happening:

Sorry, your code does not pass. Hang in there.
Your event listener should take cart.clearCart.bind(cart) as the callback.

This is my code:

clearCartBtn.addEventListener(“click”, () => cart.clearCart.bind(cart)());

who can tell me why ?

Your code so far

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

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

clearCartBtn.addEventListener("click", () => cart.clearCart.bind(cart)());

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 60

The code in the hint is the code you should put as a callback. You are putting the code inside an arrow function instead.

1 Like

Thank you very much! You are right!

1 Like