0👍
✅
You can use reduce()
method for this like:
var datiedu2 = {
"labels": ['Lavori non terminati', 'Lavori in corso'],
"datasets": [{
label: 'Numero',
data: arrayItem.reduce((a, b) => a + ((b['Value 1'] || 0) + (b['Value 2'] || 0)), 0),
backgroundColor: 'rgb(255, 99, 132)',
borderWidth: 1
}]
};
Source:stackexchange.com