Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
darul75 committed Feb 17, 2016
1 parent 9e839d5 commit 2f8a935
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions _posts/en/2016-xx-xx-reminders-about-reduce-function-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ var combineTotalPriceReducers = function(reducers, initialState) {
Now let's see how using it.

```javascript
var bigTotalPriceReducer = combineTotalPriceReducers(reducers, {dollars: 0, euros:0, yens: 0, pounds: 0});
var firstPrice = items[0].price;

var initialState = {dollars: firstPrice, euros:firstPrice, yens: firstPrice, pounds: firstPrice};

var bigTotalPriceReducer = combineTotalPriceReducers(reducers, initialState);

var totals = items.reduce(bigTotalPriceReducer);

console.log(totals);

/*
Object {dollars: 1005.11531904, euros: 1005.11531904, yens: 127514.24, pounds: 775.81131152}
Object {dollars: 1130, euros: 1015.11531904, yens: 127524.24, pounds: 785.81131152}
*/
```

Expand All @@ -117,7 +121,3 @@ I hope this approach can give you another idea of using reduce() function for yo
Your reduce function could handle an history of each computation by instance as it is done in Ramdajs with [scan](http://ramdajs.com/docs/#scan) function

[JSFiddle to play with](https://jsfiddle.net/darul75/81tgt0cd/)




0 comments on commit 2f8a935

Please sign in to comment.