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

Implementing `inc` and `dec` logic

Let's now implement the logic of these two methods. Firstly, inc. We're passing in the item that the user wants to increment. So we can simply just go 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 like that.

methods: {
  addItem: function(index) {...},
  inc: function(item) {
    item.qty++;
    this.total += item.price;
  },
  dec: function(item) {...}
}

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


Click to load comments...