Last active
October 15, 2015 15:06
-
-
Save nkt/0551bbf3c7c262242048 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function todoReducer(state, action) { | |
switch (action.type) { | |
case 'ADD_TODO': | |
return [action.payload, ...state]; | |
default: | |
return state; | |
} | |
} | |
const actions = [ | |
{ | |
type: 'ADD_TODO', | |
payload: 'Learn Redux' | |
}, | |
{ | |
type: 'ADD_TODO', | |
payload: 'Learn React' | |
} | |
]; | |
const initialState = []; | |
const currentState = actions.reduce(todoReducer, initialState); | |
assert.equals([ | |
'Learn Redux', | |
'Learn React' | |
], currentState); | |
const nums = [1, 2, 3]; | |
const sum = nums.reduce((res, value) => { | |
return res + value; | |
}, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment