Skip to content

Instantly share code, notes, and snippets.

@opheliasdaisies
Last active January 4, 2016 02:19
Show Gist options
  • Save opheliasdaisies/8553778 to your computer and use it in GitHub Desktop.
Save opheliasdaisies/8553778 to your computer and use it in GitHub Desktop.
example of a closure for blog post
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