javascript - Combinig array values with underscore.js -


I managed to map a coffee, which reduces me to exit the database.

  Inputre = _.Map _. Group by (Inputrz, 'Value'), (V, K) - & gt; {Price: K, Money_Amount: _.Redus (v, (m, i) -> m + i ['money_mount']), 0), product_mount: _.rads (v, (m, ii) I sorted sorted   

The table with the result is

1/2/2

2/10/5

3/9/3 < P> Where the amount of product divided by price is now counting the combined product to start from the first row and count down To get the fourth column is to be. Example:

1/2/2/2 (2 products only)

2/10/5/7 (5 + the 2 ago)

3 / 9/3/12 (before all 3 +)

I tried to do it in Junkery reasons because my head starts exploding when there is a lack of thinking about the map. Before creating some weird table row. Hope someone can help me.

Thank you very much.

A classic classic case for a total of low It has to be done so that it reduces another to calculate the running total after sorting and to hide it in the object, as is something:

  running_total = ( T, p) - & gt; P = Total + T + P Product _ (sort). Running_Total, 0   

This will sort you in a way:

  sorted = {value: 1, plus: 2, product: 2, total: 2 } {Value: 2, money: 10, product: 5, total: 7} {value: 3, wealth: 9, product: 3, total: 10}]   

demo: < / p>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -