Last active
January 4, 2016 02:19
-
-
Save opheliasdaisies/8553778 to your computer and use it in GitHub Desktop.
example of a closure for blog post
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
function target(threat){ | |
function attack(weapon){ | |
return 'You attack a ' + threat + ' with a ' + weapon + '.'; | |
} | |
return attack; | |
} | |
var targetZombie = target("zombie"); | |
targetZombie("chainsaw"); | |
var targetWarewolf = target("warewolf"); | |
targetWarewolf("silver bullet"); | |
var targetVampire = target("vampire"); | |
targetVampire("wooden stake"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment