Created
March 5, 2019 11:11
-
-
Save abhinavnigam2207/d39e247bbcdd4fd4c7049581d48b074e to your computer and use it in GitHub Desktop.
Make the syntax work sum(1)(2)(3).......() [Asked in multiple interviews]
This file contains 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 sum(a) { | |
return function(b) { | |
if(b){ | |
return sum(a+b); | |
} | |
return a; | |
} | |
} | |
/* ES 6 Version of the code */ | |
// sum => a => b => b ? sum(a+b) : a; | |
sum(1)(2)(3)(4)(5)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment