Skip to content

Instantly share code, notes, and snippets.

@aereal
Created July 1, 2014 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aereal/5b2fd74b1f78f00fbde7 to your computer and use it in GitHub Desktop.
Save aereal/5b2fd74b1f78f00fbde7 to your computer and use it in GitHub Desktop.
function logicalConjunction (criteria) {
return criteria.reduce(function (f, g) {
return function () { return f.apply(this, arguments) && g.apply(this, arguments) };
});
}
@aereal
Copy link
Author

aereal commented Jul 1, 2014

var isCommonDiviser = logicalConjunction([function (n) { return n % 3 === 0 }, function (n) { return n % 5 === 0 }]);
isCommonDiviser(15); //=> true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment