I am stuck with this array:
[ [ 'TWENTY', 20 ],
[ 'TWENTY', 20 ],
[ 'TWENTY', 20 ],
[ 'TEN', 10 ],
[ 'TEN', 10 ],
[ 'FIVE', 5 ],
[ 'FIVE', 5 ],
[ 'FIVE', 5 ],
[ 'DOLLAR', 1 ],
[ 'QUARTER', 0.25 ],
[ 'QUARTER', 0.25 ],
[ 'DIME', 0.1 ],
[ 'DIME', 0.1 ],
[ 'PENNY', 0.01 ],
[ 'PENNY', 0.01 ],
[ 'PENNY', 0.01 ],
[ 'PENNY', 0.01 ] ]
My goal is to combine the values so that I end up with:
[ [ 'TWENTY', 60 ],
[ 'TEN', 20 ],
[ 'FIVE', 15 ],
[ 'DOLLAR', 1 ],
[ 'QUARTER', 0.50 ],
[ 'DIME', 0.2 ],
[ 'PENNY', 0.04 ]]
I attempted to go through each element in the array and add up the values, but unfortunately, it didn't work out as expected. I would greatly appreciate any assistance. Mattia P