Javascript Number getRandom(low, high)
Number.prototype.getRandom = function(low, high) { "use strict"; //from www . ja va2 s .co m if ((low === undefined) || (high === undefined)){ low = 1; high = 10; } var randomNumber = 0; //calculate the random number randomNumber = Math.round(Math.random() * (high - low)) + low; return randomNumber; }; Number.prototype.easterEgg = "Drew added this hidden prop";
/*jshint browser:true */ /*jshint devel:true */ // modifying the prototype of the number objects. Number.prototype.getRandom = function(low, high){ 'use strict';/*from w w w . ja va2 s . c o m*/ var randomNumber; // hacking overloading if((low === undefined) || (high === undefined)){ low = 1; high = 10; } //calculate the random number randomNumber = Math.round(Math.random() * (high - low)) + low; return randomNumber; }; Number.prototype.easterEgg = "This is easter egg!!";