I have an array of objects like this:
arr = [
{ a: "dog", b: 8, c: "male", d: "big", e: 100 },
{ a: "dog1", b: 5, c: "female", d: "big", e: 200},
{ a: "dog2", b: 18, c: "female", d: "big", e: 350},
{ a: "dog2", b: 18, c: "female", d: "big", e: 350},
{ a: "dog", b: 3, c: "male", d: "big", e: 100 },
{ a: "dog", b: 8, c: "male", d: "big", e: 100 },
];
I want to create a new array containing only the property a and the sum of e of those objects that have the same values for b, c and d, so that I'll have and array like this:
arr2 = [
{ a: "dog", e: 300 },
{ a: "dog2", e: 700},
];
I've already tried to use a map function inside a map function looking for the elements that have the same properties b, c and d, then pushing the result in the arr2, but it pushes every time all the objects of my initial arr.
reduce