I have two arrays
var arrayA = ["a", "a", "b", "b", "a", "c"];
var arrayB = [10, 20, 3, 2, 20, 5];
As you can see, arrayA[0], arrayA[1], arrayA[4]
have an same elements (arrayA[2], arrayA[3]
same too).
So based on above example, I want arrayB[0], arrayB[1], arrayB[4]
will be summed up, and arrayB[2], arrayB[3]
too.
expectation output
arrayA = ["a", "b", "c"];
arrayB = [50, 5, 5];
It's possible to sum the arrayB elements if arrayA have same elements based arrayA index? and is there an Lodash/Underscore function to do this?