Skip to content

Instantly share code, notes, and snippets.

@supasympa
Created March 5, 2019 10:51
Show Gist options
  • Save supasympa/f6fe83d4d270f3337fc7526fbc8ad675 to your computer and use it in GitHub Desktop.
Save supasympa/f6fe83d4d270f3337fc7526fbc8ad675 to your computer and use it in GitHub Desktop.
a simple example of functional programming / chaining
const addFive = (v) => (v + 5);
const timesTen = (v) => (v * 10);
const toObj = (v) => ({value: v});
const addFiveTimesTenObj = (v) => [addFive, timesTen, toObj].reduce((acc, item) => (item(acc)), v);
console.log(addFiveTimesTenObj(123));
console.log(addFiveTimesTenObj(13));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment