Skip to content

Instantly share code, notes, and snippets.

@sunnyy02
Created December 7, 2021 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnyy02/27df5f94de199063fd6fc533174146b7 to your computer and use it in GitHub Desktop.
Save sunnyy02/27df5f94de199063fd6fc533174146b7 to your computer and use it in GitHub Desktop.
compose =
(...fns) =>
(initialVal) =>
fns.reduceRight((val, fn) => fn(val), initialVal);
const getDiscountedPrice = compose(applyVipOffer, applyFixDiscount);
console.log('price:', getDiscountedPrice2(100)) // 40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment