After some tinkering, I successfully streamlined my Price Amount Object by combining it like so:
stooges = [{Price: 1.2, Amount: 40}, {Price: 1.3, Amount: 50}, {Price: 1.2, Amount: 60}];
inputarray = _.map _.groupBy(stooges, 'Price'), (v, k) ->
{ Price: k
Amount : _.reduce(v, ((m, i) -> m + i['Amount']), 0)}
console.log(inputarray)
This code generates the following output:
[Object { Price="1.2", Amount=100}, Object { Price="1.3", Amount=50}]
Although I feel the grouping might be excessive, I aim to achieve a structure similar to this:
[ { 1.2 : 100 } , { 1.3 : 50 } ]
Where the Price serves as the Key and the Amount acts as the Value. Struggling a bit with this one.