Created
May 13, 2019 20:35
-
-
Save nadeesha/5238b1d145945c5fcdaf2b5a146ba57c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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