Skip to content

Instantly share code, notes, and snippets.

@jafow
Created December 8, 2015 05:59
Show Gist options
  • Save jafow/166a7068654095167326 to your computer and use it in GitHub Desktop.
Save jafow/166a7068654095167326 to your computer and use it in GitHub Desktop.
simple example of compose
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