Is there any way to group a Json using the Reduce()
method of Javascript, as the example 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}];
that returns as follows:
contas = [{id:1, descricao: "AGUA", valor: 200, juros: 10},
{id:2, descricao: "LUZ", valor: 300, juros: 20}];
Any suggestions?