Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import { compose, both, either, gte, prop, equals, __ } from "ramda"
  2.  
  3. const OUR_COUNTRY = "France"
  4.  
  5. const wasBornInCountry = compose(
  6. equals(OUR_COUNTRY),
  7. prop("birthCountry"),
  8. )
  9. const wasNaturalized = compose(
  10. Boolean,
  11. prop("naturalizationDate"),
  12. )
  13. const isOver18 = compose(
  14. gte(__, 18),
  15. prop("age"),
  16. )
  17.  
  18. const isCitizen = either(wasBornInCountry, wasNaturalized)
  19.  
  20. const isEligibleToVote = both(isOver18, isCitizen)
  21.  
  22. console.log(isCitizen({ age: 21, birthCountry: "France" }))
  23. console.log(isEligibleToVote({ age: 21, birthCountry: "Wakanda", naturalizationDate: "someDate" }))
  24. console.log(isEligibleToVote({ age: 16, birthCountry: "France" }))
Add Comment
Please, Sign In to add comment