Skip to content

Instantly share code, notes, and snippets.

@leonidkuznetsov18
Last active December 4, 2019 11:50
Show Gist options
  • Select an option

  • Save leonidkuznetsov18/c0b748d4ad9bce4618eaee8a07b5451d to your computer and use it in GitHub Desktop.

Select an option

Save leonidkuznetsov18/c0b748d4ad9bce4618eaee8a07b5451d to your computer and use it in GitHub Desktop.
Sum Curry Functions
function sum(...arg) {
function sumReturn(...arg2) {
return sum(...arg, ...arg2)
}
let total = arg.reduce((total, val) => total + val);
sumReturn.value = total;
return sumReturn;
}
console.log(sum(5)(7)(1)()(7)(2)(4).value); // 26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment