3
Is there any way to group a Json using the method Reduce()
of Javascript, as shown below:
contas = [{id: 1, descricao: "AGUA", valor: 100, juros: 5},
{id: 1, descricao: "AGUA", valor: 100, juros: 5},
{id: 2, descricao: "LUZ", valor: 150, juros: 10},
{id: 2, descricao: "LUZ", valor: 150, juros: 10}];
returning in the following manner:
contas = [{id:1, descricao: "AGUA", valor: 200, juros: 10},
{id:2, descricao: "LUZ", valor: 300, juros: 20}];
Any suggestions?
Perfect! That’s just what I needed, thank you!
– José