Created
November 4, 2018 15:35
-
-
Save Expl4Life/0c19ba2b70931b0bbaf6344fd1bafa3f to your computer and use it in GitHub Desktop.
Closure. Sum function
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(a) { | |
let currentSum = a; | |
function f(b) { | |
currentSum += b; | |
return f; | |
} | |
f.toString = function () { | |
return currentSum; | |
}; | |
return f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment