payroll.forEach(function(d) {
if (holder.hasOwnProperty(d.position)) {
holder[d.position] = holder[d.position] + parseFloat(d.salary.amount);
console.log(d.salary.amount)
} else {
holder[d.position] = d.salary.amount;
}
});
var obj2 = [];
for (var prop in holder) {
obj2.push({ position: prop, value : holder[prop]})
}
this is the code I'm using to get sum of values of repeated objects which logs out like this
[
{
position: 'Orchestrator',
value: '8975.554485.94395.964368.216586.67'
},
{
position: 'Architect',
value: '5245.225750.278045.965354.83236.725290.66'
},
{
position: 'Liaison',
value: '3268.926869.663252.068490.317352.638997.826831.56'
},
]
payroll is a big file with lot of repeated objects for example Orchestrator has values 8975.55, 4485.9, { 4395.96, 4368.21, 6586.67 } but logs out concatenated even after parsing.
After searching for a while, i figured out I need to parse each element in d.salary.amount how to do that?
Thanks