Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Last active October 27, 2020 07:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ericelliott/f6a87bc41de31562d0f9 to your computer and use it in GitHub Desktop.
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
// 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