Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anubhavsrivastava/b6301e95b7b405b6fb548a194a7c20f4 to your computer and use it in GitHub Desktop.
Save anubhavsrivastava/b6301e95b7b405b6fb548a194a7c20f4 to your computer and use it in GitHub Desktop.
function add(x){
let sum = x;
return function resultFn(y){
if(arguments.length){ //not relying on falsy value
sum += y;
return resultFn;
}
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment