Skip to content

Instantly share code, notes, and snippets.

@peterpme
Last active August 29, 2015 13:57
Show Gist options
  • Save peterpme/9510683 to your computer and use it in GitHub Desktop.
Save peterpme/9510683 to your computer and use it in GitHub Desktop.
CodeWars Wrap Function
function speak(name){
return "Hello " + name;
}
Function.prototype.wrap = function(fn){
var that = this;
console.log(that);
return function(arg2,arg3){
return fn(that,arg2,arg3);
};
};
speak = speak.wrap(function(original, yourName, myName){
greeting = original(yourName);
return greeting + ", my name is " + myName;
});
var greeting = speak("Mary", "Kate");
console.log(greeting);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment