Skip to content

Instantly share code, notes, and snippets.

@thmain
Created December 25, 2022 05:30
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 thmain/ddb5c4f6b7a71cd6376dd3dd8394e359 to your computer and use it in GitHub Desktop.
Save thmain/ddb5c4f6b7a71cd6376dd3dd8394e359 to your computer and use it in GitHub Desktop.
let sentence = ''
function say () {
if ( !arguments[0] ) {
let s = sentence
sentence = ''
return s
} else {
sentence += arguments[0] + ' '
// Note: This is not a recursion
return say
}
}
console.log( say('Foo')('bar')() ) // => "Foo bar "
console.log( say('Hi')('my')('name')('is')('Foo')() ) // "Hi my name is Foo "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment