Skip to content

Instantly share code, notes, and snippets.

@Expl4Life
Created November 4, 2018 15:35
Show Gist options
  • Save Expl4Life/0c19ba2b70931b0bbaf6344fd1bafa3f to your computer and use it in GitHub Desktop.
Save Expl4Life/0c19ba2b70931b0bbaf6344fd1bafa3f to your computer and use it in GitHub Desktop.
Closure. Sum function
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