Skip to content

Instantly share code, notes, and snippets.

@evaporei
Last active September 26, 2017 02:44
Show Gist options
  • Save evaporei/3515ed6b88d79fa3c0a9e6cc43f0b737 to your computer and use it in GitHub Desktop.
Save evaporei/3515ed6b88d79fa3c0a9e6cc43f0b737 to your computer and use it in GitHub Desktop.
Ramda functional exercise 4 - Get users in their thirties
const R = require('ramda')
const json = {
users: [
{id: 3, name: "Thad", age: 36},
{id: 5, name: "Lucian", age: 23},
{id: 2, name: "Justine", age: 29},
{id: 4, name: "Katie", age: 26},
{id: 0, name: "Jerold", age: 52},
{id: 1, name: "Nona", age: 33}
]
}
// exercise 4: get users in their thirties
const isInThirties = R.both(
R.gt(R.__, 29),
R.lt(R.__, 40)
)
const userIsInThirties = R.propSatisfies(isInThirties, 'age')
const usersInThirties = R.filter(userIsInThirties)(json.users)
console.log(usersInThirties)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment