How to sum all values of selected checkbox?

Hello.
This list of checkbox's https://jsfiddle.net/zt8hL9w7/ the choice of which displays their sum. But I need the value of each point is pre-calculated according to the formula. For example, if you select 1 Checkbox its value is multiplied by the value of any input's on the page, and the result to pass to the function summation, and similarly for the others.
Where in the code to register these functions?

And yet I noticed that if in my example checkbox's have the same value, then they are all together in a group. How to fix it?
April 7th 20 at 15:22
2 answers
April 7th 20 at 15:24
Solution
April 7th 20 at 15:26
You can use the getters. For example something like this:
class CheckBoxCalc {
 constructor(text, callback) {
 this.text = text
 this.cb = callback
}

 get value() {
 return this.cb()
}
}


new Vue({
 el: "#app",
 data: {
 checkedNumbers: [],
 checkbox: [
 new CheckBoxCalc('Checkbox 1', () => 10),
 new CheckBoxCalc('Checkbox 2', () => Math.floor(Date.now() / 10000000)),
 new CheckBoxCalc('Checkbox 3', () => Math.floor(Math.random() * 100)),
]
},
 computed: {
 sum() {
 return this.checkedNumbers.reduce((acc, index) => {
 return acc + this.checkbox[index].value
 }, 0);
}
}
})

Looks a little collective, but there you yourself will bring to mind

Find more questions by tags Vue.js