Created
October 29, 2016 01:31
-
-
Save kr094/3789e1ee015bad9a81fe3938187f996d 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
<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