RPeraltaJr
2/27/2018 - 10:21 PM

Adding all values of each product

const app = new Vue({
    el: '#app',
    data: {
        products: []
    },
    computed: {
        totalProducts() {
            // add all the quantities of each product
            return this.products.reduce((sum, product) => {
                return sum + product.quantity
            }, 0)
        }
    }
})