Last active
September 5, 2016 15:20
-
-
Save alexeykomov/41e7f67497af13c9c46c7513222bb2e3 to your computer and use it in GitHub Desktop.
This file contains 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(allPreviousSum) { | |
var newFunction = function(newMember){return sum(allPreviousSum + newMember)} | |
newFunction.valueOf = function(){return allPreviousSum} | |
return newFunction; | |
} | |
console.log(sum(1) == 1); | |
console.log(sum(1)(2) == 3); | |
console.log(sum(1)(2)(3) == 6); | |
console.log(sum(1)(2)(3)(4) == 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment