Created
August 5, 2018 15:50
-
-
Save anirudh-eka/ac04e7c74741f40b1dc5175e9919ddbd 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
| const mapAdd1Reducer = (a, x) => { | |
| const transformed = x + 1; | |
| return a.concat(transformed) | |
| } | |
| const filterGreaterThan2Reducer = (a, x) => { | |
| if(x > 2) { | |
| return a.concat(x) | |
| } else { | |
| return a; | |
| } | |
| } | |
| [1, 2, 3] | |
| .reduce(filterGreaterThan2Reducer, []) | |
| .reduce(mapAdd1Reducer, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment