课程: JavaScript: Five Advanced Challenges and Concepts

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Create a Reactive shopping cart

Solution: Create a Reactive shopping cart

(bright music) - [Instructor] The answer code for the shopping cart challenge contains the running tally array, which is currently empty. Then a framework for a reactive object, and finally a function here at the bottom called Tally cart. This is the information that grabs all the information about the current value of the cart and pushes it to the running tally array. To solve this challenge, we need to build out a shopping cart class with methods for adding and removing items and updating the totals of those items and then notifying tally cart anytime this happens so that we enter in the new tally for the cart. To start, let's create the shopping cart class. This class extends reactive object because we want it to be reactive and we're pulling in all the features of the reactive object. Then we set up an items array and properties for the total before tax. The GST, the PST and Sum total. These will be the values that are…

内容