Created
February 3, 2019 16:28
-
-
Save anubhavsrivastava/b6301e95b7b405b6fb548a194a7c20f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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