Learn Basic OOP by Building a Shopping Cart - Step 43

Tell us what’s happening:

I am so stuck the clues aren’t helping could someone write me an example so I can understand the syntax and where to put what

Your code so far

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

/* file: styles.css */

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

calculateTotal() {
   const subTotal = items.reduce((total, item)=> total + item.price, 0);
 }
  this.items.forEach((total + items.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

Hi there @julieperk

You only need to add reduce method within the calculateTotal method. and items array should be used with this keyword when you attachs reduce to it.

2 Likes

you should have only one line of code, your this keyword should be assigned to your subTotal variable. you don’t need the second line at all.

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