Tell us what’s happening:
calculateTotal() {
const subTotal = this.items.reduce((total, item) => total + item.price, 0);
const tax = this.calculateTaxes(subTotal);
this.total = subTotal + tax;
cartSubTotal.textContent = $${subTotal.toFixed(2)}
;
cartTaxes.textContent = $${this.tax.toFixed(2)}
;
cartTotal.textContent = $${this.total.toFixed(2)}
;
I can’t figure out what’s wrong.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
calculateTotal() {
const subTotal = this.items.reduce((total, item) => total + item.price, 0);
const tax = this.calculateTaxes(subTotal);
this.total = subTotal + tax;
cartSubTotal.textContent = `$${subTotal.toFixed(2)}`;
cartTaxes.textContent = `$${this.tax.toFixed(2)}`;
cartTotal.textContent = `$${this.total.toFixed(2)}`;
}
// User Editable Region
/* file: styles.css */
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/18.3 Safari/605.1.15
Challenge Information:
Learn Basic OOP by Building a Shopping Cart - Step 51