diff options
| author | lizhineng <[email protected]> | 2013-06-07 23:30:20 +0800 |
|---|---|---|
| committer | lizhineng <[email protected]> | 2013-06-07 23:30:20 +0800 |
| commit | 006b98dfd0ae1fbc34ef4c135e4ab07a7b82b152 (patch) | |
| tree | 86b42eba1c29afebec82040e9856bbe5302d8add /js/utility.js | |
| parent | c080e07ee1a0004d732508f9ed011678a38eda5e (diff) | |
| download | word-search-game-006b98dfd0ae1fbc34ef4c135e4ab07a7b82b152.tar.gz word-search-game-006b98dfd0ae1fbc34ef4c135e4ab07a7b82b152.zip | |
optimized the expressions and fixed some bugs
Diffstat (limited to 'js/utility.js')
| -rw-r--r-- | js/utility.js | 17 |
1 files changed, 14 insertions, 3 deletions
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; +} |
