-
-
Save easierbycode/8678535 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var friendlify = function (fn, log) { | |
var patsOnTheBack = [ | |
'you are great', | |
'you\'re the best', | |
'wow you\'re awesome' | |
]; | |
log = log || console.log; | |
return function () { | |
var args = arguments; | |
log(patsOnTheBack[Math.floor(patsOnTheBack.length * Math.random())] + '!'); | |
return fn.apply(this, args); | |
}; | |
}; | |
// usage: | |
/* | |
var three = friendlify(function () { return 3; }); | |
three(); | |
// log: you are great! | |
// returns: 3 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment