Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { compose, both, either, gte, prop, equals, __ } from "ramda"
- const OUR_COUNTRY = "France"
- const wasBornInCountry = compose(
- equals(OUR_COUNTRY),
- prop("birthCountry"),
- )
- const wasNaturalized = compose(
- Boolean,
- prop("naturalizationDate"),
- )
- const isOver18 = compose(
- gte(__, 18),
- prop("age"),
- )
- const isCitizen = either(wasBornInCountry, wasNaturalized)
- const isEligibleToVote = both(isOver18, isCitizen)
- console.log(isCitizen({ age: 21, birthCountry: "France" }))
- console.log(isEligibleToVote({ age: 21, birthCountry: "Wakanda", naturalizationDate: "someDate" }))
- console.log(isEligibleToVote({ age: 16, birthCountry: "France" }))
Add Comment
Please, Sign In to add comment