Created
February 2, 2021 12:36
-
-
Save smkhalsa/eec8c56364ff5027122af84197d7586e to your computer and use it in GitHub Desktop.
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
// Easier to understand version | |
function addMany(num) { | |
return (next) => { | |
if (next === undefined) { | |
return num; | |
} else { | |
return addMany(num + next) | |
} | |
} | |
} | |
// Concise version | |
function addMany(num) { | |
return next => next === undefined ? num : addMany(num + next) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment