Last active
December 4, 2019 11:50
-
-
Save leonidkuznetsov18/c0b748d4ad9bce4618eaee8a07b5451d to your computer and use it in GitHub Desktop.
Sum Curry Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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