Created
September 26, 2017 07:26
-
-
Save cezarneaga/ed372f4e8e5b7477ee4a85a27ac50c8f to your computer and use it in GitHub Desktop.
Filter an array by date condition and return certain props only with Ramda.
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 array = [{id: 1, createdAt: '2016-09-22 15:55:08'}, {id: 2, createdAt: '2017-11-22 15:55:08'}] | |
const dateCheck = date => | |
new Date(date).getFullYear() >= new Date().getFullYear() | |
R.pluck('id', R.filter(R.propSatisfies(dateCheck, 'createdAt'))(array)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what are the ways one could do this better?