I am struggling to solve this problem.
For each customer, I have an array object representing each month of the year:
[
{
color: "#009192",
data: [0, 0, 57.62, 0, 0, 0, 0, 0, 0, 0, 0, 0],
label: "Client 1"
},
{
color: "#009192",
data: [0, 0, 234.65, 0, 0, 0, 0, 0, 0, 0, 0, 0],
label: "Client 2"
},
{
color: "#009192"
data: [0, 0, 490.43, 0, 0, 0, 0, 0, 0, 0, 0, 0]
label: "Client 3"
},
{
color: "#009192"
data: [0, 0, 0, 94.00, 0, 0, 0, 0, 0, 0, 0, 0]
label: "Client 1"
}
]
How can I combine the two objects with the same label (Client 1) and create a new array like this?
[
{
color: "#009192",
data: [0, 0, 57.62, 94.00, 0, 0, 0, 0, 0, 0, 0, 0],
label: "Client 1"
},
{
color: "#009192",
data: [0, 0, 234.65, 0, 0, 0, 0, 0, 0, 0, 0, 0],
label: "Client 2"
},
{
color: "#009192"
data: [0, 0, 490.43, 0, 0, 0, 0, 0, 0, 0, 0, 0]
label: "Client 3"
},
]
Appreciate your help!