From 74cf89ed3ae2ab74a170366c19e8e8618a3f92c3 Mon Sep 17 00:00:00 2001 From: Kenneth Blomqvist Date: Thu, 11 Jul 2013 20:54:08 +0300 Subject: [PATCH] Add javascript support --- beers.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 beers.js diff --git a/beers.js b/beers.js new file mode 100644 index 0000000..e6f50bb --- /dev/null +++ b/beers.js @@ -0,0 +1,40 @@ +console.log("Time for a beer run...") + +setTimeout(function() { + String.prototype.repeat = function( num ) + { + return new Array( num + 1 ).join( this ); + } + + var BEER = "🍺 "; + var DOUBLEBEER ="🍻 "; + + Number.prototype.beers = function() { + return BEER.repeat(this); + } + + Number.prototype.doubleBeers = function() { + return DOUBLEBEER.repeat(this); + } + + Number.prototype.pack = function() { + function genPack(rows, cols){ + return (cols.beers() + "\n").repeat(rows) + } + if (this == 6) { return genPack(2, 3);} + else if (this == 12) {return genPack(2, 6);} + else if (this == 18) {return genPack(3, 6);} + else if (this == 24) {return genPack(4, 6);} + } + + Math.random.beers = function(num) { + if (num == undefined) {var num = 10;} + return BEER.repeat(Math.floor(this() * num)); + } + + Date.now.beer = function(){ + return true; + } + + console.log('Done!'); +}, 2500)