i have data array in this
"item_tabel": [
{
"method": {
"select_method": 6,
},
"innovation": {
"select_innovation": 2,
},
}
],
how to calculate using sum ?
this my computed
subtotalRow() {
return this.$store.state.item_tabel.map((item,i) => {
return Number(item.method.select_method * item.innovation.select_innovation)
//how to sum (item.method.select_method + item.innovation.select_innovation)
});
},
example in my table
No | method | inov | total
1 | 6 | 2 | (6+2 = 8) //calculate
2 | 2 | 2 | 4 //calculate
if using operator * works and if using + doesn't work
thks
Since a callback function is required by Array.map() so the function body is supposed to be enclosed in braces '{}'
subtotalRow() {
return this.$store.state.item_tabel.map(
(item,i) => {item.method.select_method + item.innovation.select_innovation}
);
},
subtotalRow() {
return this.$store.state.item_tabel.map(
(item,i) => (item.method.select_method + item.innovation.select_innovation)
);
},