Learn Basic OOP by Building a Shopping Cart - Step 16

Tell us what’s happening:

Error message: “You should use [this] keyword to set the [items] property of your class to an empty array.”

What am I doing wrong here?

Your code so far

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

/* file: styles.css */

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

class ShoppingCart {
  constructor() {
    this.items = [];
    total = 0;
    taxRate = 8.25;  

  }
};

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 16

set the total property to 0 , and the taxRate property to 8.25

Those are also properties of the class, you still need to use this

1 Like

Thanks for the help. Though the error message seems bugged as it was pointing me to the this.items property.

The error message is stuck because you get a syntax error in the console, specifically

[ReferenceError: total is not defined]