SHARE
TWEET

Untitled

a guest May 26th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const compose = (...funcs) => {
  2.   return value => {
  3.     return funcs.reduceRight((acc, func) => func(acc), value);
  4.   }
  5.  
  6. }
  7.  
  8. const number = 15
  9. const increment = num => num + 5
  10. const decrement = num => num - 3
  11. const multiply = num => num * 2
  12.  
  13. const funcComposition = compose(
  14.   increment,
  15.   decrement,
  16.   multiply
  17. )
  18.  
  19. const result = funcComposition(number)
  20. console.log(result)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top