Skip to content

Instantly share code, notes, and snippets.

@abhinavnigam2207
Last active March 5, 2019 10:52
Show Gist options
  • Save abhinavnigam2207/96115880451fce9a6567a1ad2102a66c to your computer and use it in GitHub Desktop.
Save abhinavnigam2207/96115880451fce9a6567a1ad2102a66c to your computer and use it in GitHub Desktop.
Make the syntax work sum(1)(2)(3).......(n) [Asked in multiple interviews]
function sum(a) {
var resp = a;
function innerSum(b) {
resp += b;
return innerSum;
}
innerSum.toString = function(){
return resp;
}
return innerSum;
}
sum(1)(2)(3)(4)(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment