Learn Basic OOP by Building a Shopping Cart - Step 43

Tell us what’s happening:

You should create a calculateTotal method in the ShoppingCart class.

what have I done wrong

Your code so far

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

/* file: styles.css */

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

new ShoppingCart (
 calculateTotal(items) {
  const subTotal = 
  this.items.reduce((total, item)=> total + item.price, 0)
)
}

// 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/130.0.0.0 Safari/537.36

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 43

You are still editing within the class you dont need this:

new ShoppingCart (

Just create a new method as you have been doing for all the other methods like additem or getcounts.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.