The video for this lesson is currently being updated, please read the transcript instead.

Adding products to the cart

The next thing we want to do is get the addToCart method to do its proper job.

It'll need to do two things: firstly, it'll need to update the total value, and secondly, it'll need to push products to the cart array so they're ready to be displayed.

We'll deal with updating the total first. Our product objects don't have a price property yet, so let's add that now. We'll give each one a price of 9.99.

products: [
  { title: "Product 1", id: 1, price: 9.99 },

To view the complete lesson you'll need to login or join this course.


Click to load comments...