Created
December 25, 2022 05:30
-
-
Save thmain/ddb5c4f6b7a71cd6376dd3dd8394e359 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
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