Implementing inc and dec logic
In the last video, we created quantity controls for our cart items and stubbed a corrosponding inc and dec method.
Let's now implement the logic of these two methods.
inc method logic
Let's begin with inc. We're passing in the item that the user wants to increment. So the logic for the quantity will simply be item.qty++.
Keep in mind we also need to increment the total value as well by the price of the item. We can do that by going this.total += item.price.
Click to load comments...