Created
December 8, 2015 05:59
-
-
Save jafow/166a7068654095167326 to your computer and use it in GitHub Desktop.
simple example of compose
This file contains 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
const makeUpperCase = (word) => word.toUpperCase(); | |
const makePlural = (word) => word + 's'; | |
makePlural('shoe');//=> 'shoes' | |
makeUpperCase('shoe');//=> 'SHOE' | |
const compose = (x, y) => { | |
return function (z) { | |
return x(y(z)); | |
}; | |
}; | |
const upperPlural = compose(makeUpperCase, makePlural); | |
upperPlural('feet'); //=> "FEETS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment