summaryrefslogtreecommitdiff
path: root/js/utility.js
diff options
context:
space:
mode:
authorlizhineng <[email protected]>2013-06-07 23:30:20 +0800
committerlizhineng <[email protected]>2013-06-07 23:30:20 +0800
commit006b98dfd0ae1fbc34ef4c135e4ab07a7b82b152 (patch)
tree86b42eba1c29afebec82040e9856bbe5302d8add /js/utility.js
parentc080e07ee1a0004d732508f9ed011678a38eda5e (diff)
downloadword-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.js17
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;
+}