I know that my question was asked a few times here, but I didn't find a working solution :(
My array in the data property is currently looking like this:
products: [{
name: 'Product A',
price: '10'
},
{
name: 'Product B',
price: '30'
},
{
name: 'Product C',
price: '20'
}]
Function to sum up the prices:
sumTotal() {
let basket_total = [];
this.products.forEach(val => {
basket_total += val.price;
});
console.log(basket_total);
}
My result is 103020 instead of 60. I also tried other ways, but every time I got the same result. What can I do?
Thanks!
basket_totalshould be a number, not an array:let basket_total = 0