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
*/