So I know how to add all the values in an array.
Example, the sum of [1,2,3,4]...
[1,2,3,4].inject(&:+)
#=> 10
However, I have an array of arrays and would like to add the values that have the same first element of each sub array.
# example
[["A", 10],["A", 5],["B", 5],["B", 5],["C", 15], ["C", 15]]
Desired output:
"(A : 15) - (B : 10) - (C : 30)"
Any help would be appreciated!