Skip to content

Instantly share code, notes, and snippets.

@smkhalsa
Created February 2, 2021 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smkhalsa/eec8c56364ff5027122af84197d7586e to your computer and use it in GitHub Desktop.
Save smkhalsa/eec8c56364ff5027122af84197d7586e to your computer and use it in GitHub Desktop.
// 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