Skip to content

Instantly share code, notes, and snippets.

@sylvaindesve
Created November 9, 2018 09:14
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 sylvaindesve/58910fa30c6a4ae410c09d7c4c519fae to your computer and use it in GitHub Desktop.
Save sylvaindesve/58910fa30c6a4ae410c09d7c4c519fae to your computer and use it in GitHub Desktop.
Javascript: right function reduction
const fn = [(x) => x + "a", (x) => x + "b", (x) => x + "c", (x) => x + "d"].reduceRight(
(accumulator, currentFn) => {
return ((x) => currentFn(accumulator(x)));
}
);
console.log(fn("test"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment