I have an array like this:
"Year:2017,Mes:8,Suma:0"
"Year:2017,Mes:8,Suma:5"
"Year:2017,Mes:8,Suma:5"
"Year:2017,Mes:8,Suma:0"
In what way can I group by month and year, add the data, so that I have another array like this?
"2017-8", "10"
This is what I try:
let datos = {
"Year:2017,Mes:8":0,
"Year:2017,Mes:8":5,
"Year:2017,Mes:8":5,
"Year:2017,Mes:8":0,
};
console.log( agrupar(datos) ); // 650
function agrupar(datos) {
let sum = 0;
for (let suma of Object.values(datos)) {
sum += suma;
}
return sum;
}
I know it's not complicated, but I can not do it.
Thanks for the help!