From 006b98dfd0ae1fbc34ef4c135e4ab07a7b82b152 Mon Sep 17 00:00:00 2001 From: lizhineng Date: Fri, 7 Jun 2013 23:30:20 +0800 Subject: optimized the expressions and fixed some bugs --- js/utility.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'js/utility.js') diff --git a/js/utility.js b/js/utility.js index ab67cd2..a59841f 100644 --- a/js/utility.js +++ b/js/utility.js @@ -1,3 +1,14 @@ -function range(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; -} \ No newline at end of file +/** + * Returns a random integer between min and max + * + * @param {Number} min + * @param {Number} max + * @return {Number} + */ +Math.rangeInt = function(min, max){ + if (max == undefined) { + max = min; + min = 0; + } + return Math.floor(Math.random() * (max - min + 1)) + min; +} -- cgit v1.2.3