Skip to content

Instantly share code, notes, and snippets.

@btford
Created June 25, 2013 21:59
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save btford/5862848 to your computer and use it in GitHub Desktop.
Save btford/5862848 to your computer and use it in GitHub Desktop.
this is why higher order programming was invented
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
*/
@ksheedlo
Copy link

💩 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment