Skip to content

Instantly share code, notes, and snippets.

@kr094
Created October 29, 2016 01:31
Show Gist options
  • Save kr094/3789e1ee015bad9a81fe3938187f996d to your computer and use it in GitHub Desktop.
Save kr094/3789e1ee015bad9a81fe3938187f996d to your computer and use it in GitHub Desktop.
<script>
/*
* Be sure to drink your Ovaltine
*
* If you are a JavaScript nerd supreme:
*/
var say = (function () {
var current = '';
var formatter = function (text) {
current += " " + text.replace(/[^\w]/, '').split("").join("-");
return formatter;
};
formatter.getText = function () {
return current;
};
return formatter;
}());
console.log(say("Domino's")("Pizza")("Rocks!").getText());
/*
* ...should all output "true"
*
* bonus for avoiding for loops
* bonus for creativity
*
* tweet a gist to @DominosCareers
*/
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment