easierbycode
1/28/2014 - 11:05 PM

index.js

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

*/