I am trying to find a way to calculate the sum of computed
properties that begin with the string calculateSum
.
The challenge is that I cannot access their names using this.computed
.
Here is my approach:
getSubTotal(){
var computed_names = [];
var computed_names_filtered = computed_names.filter(x => {return x.startsWith('calculateSum')})
return _.sum(computed_names_filtered.map(x => eval(x+'()'))
}
Can you think of another way to achieve this task?