Created
July 18, 2019 17:26
-
-
Save chalu/b027009ecdad6d92be9c21580c775cbb 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 match = (field, delegate) => { | |
| return (data = []) => { | |
| return data.filter(entry => delegate(entry[field])); | |
| } | |
| }; | |
| const isMale = (value) => value === 'male'; | |
| const isFemale = (value) => value === 'female'; | |
| const getMales = match('gender', isMale); | |
| const getFemales = match('gender', isFemale); | |
| const males = getMales(data); | |
| const females = getFemales(data); | |
| console.log(`we've got ${females} femalse and ${males} males`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment