I use Node.js a lot for scripting like this. It's much easier and a more powerful alternative to bash scripts.
I'll use node for Unix scripting when you pry every other alternative from my cold dead hands:
awk '{a[$2] += $3};END{for(x in a){print x, a[x]}}' sample.txt
A 2
B 14
C 6