Created
February 3, 2019 17:11
-
-
Save anubhavsrivastava/50236dde3561454708d57830398b1226 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(){ | |
let args = [].slice.apply(arguments); | |
function resultFn(){ | |
args = args.concat([].slice.apply(arguments)); | |
if(args.length>=3){ | |
return args.slice(0,3).reduce(function(acc,next){ return acc+next},0) | |
} | |
return resultFn | |
} | |
return resultFn(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment