Skip to content

Instantly share code, notes, and snippets.

@nadeesha
Created May 13, 2019 20:35
Show Gist options
  • Save nadeesha/5238b1d145945c5fcdaf2b5a146ba57c to your computer and use it in GitHub Desktop.
Save nadeesha/5238b1d145945c5fcdaf2b5a146ba57c to your computer and use it in GitHub Desktop.
// imperative
if (name.includes("food")) {
return `${name} is food`;
} else {
return `${name} is not food`;
}
// declarative
const getProductClassification = conditionally({
if: name => name.includes("foo"),
then: name => `${name} is food`,
else: name => `${name} is not food`,
});
getProductClassification("cat food");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment