0👍
To get all array items that have a falsy B1
value, use Array.prototype.filter
:
const falsyB1Items = this.Array1.filter(item => !item.B1)
Then you could reduce those items:
return falsyB1Items.reduce((sum, numbers) => sum += numbers.Numbers, 0)
- [Vuejs]-How to use put methode on vue js + node
- [Vuejs]-How to hide some dynamically generated div's in VueJS v-for
0👍
You can do it just by one function like this:
computed: {
sumOfNumbers() {
this.Array1.map(obj => {
if (obj.B1 === false) {
this.sum += obj.Numbers; // The sum is stored in the 'sum' var
}
});
return this.sum;
}
}
Does it works the way you want?
Source:stackexchange.com