Last active
October 27, 2020 07:08
-
-
Save ericelliott/f6a87bc41de31562d0f9 to your computer and use it in GitHub Desktop.
Secret - creates closures with secret messages. https://jsbin.com/hitusu/edit?html,js,output
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
// Secret - creates closures with secret messages. | |
// https://gist.github.com/ericelliott/f6a87bc41de31562d0f9 | |
// https://jsbin.com/hitusu/edit?html,js,output | |
// secret(msg: String) => getSecret() => msg: String | |
const secret = (msg) => () => msg; | |
test('secret', assert => { | |
const msg = 'secret() should return a function that returns the passed secret.'; | |
const theSecret = 'Closures are easy.'; | |
const mySecret = secret(theSecret); | |
const actual = mySecret(); | |
const expected = theSecret; | |
assert.equal(actual, expected, msg); | |
assert.end(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment