Created
August 22, 2016 17:00
-
-
Save ericelliott/84599283f9afac83a4b7ebc515be9014 to your computer and use it in GitHub Desktop.
Simple reducer example http://codepen.io/ericelliott/pen/bZyqQy?editors=0012
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = 0; | |
const reducer = (state = initialState, data) => state + data; | |
const total = [0, 1, 2, 3].reduce(reducer); | |
console.log(total); // 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment