aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/random.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/random.js b/lib/random.js
index 63347278..6205dc09 100644
--- a/lib/random.js
+++ b/lib/random.js
@@ -1,13 +1,12 @@
var definitions = require('./definitions');
var random = {
// returns a single random number based on a max number or range
- number: function (range) {
- if(Array.isArray(range)) {
- var min = range[0];
- var max = range[1];
- return Math.floor((Math.random() * max) + min);
+ number: function (min, max) {
+ if (max === undefined) {
+ max = min;
+ min = 0;
}
- return Math.floor(Math.random() * range);
+ return Math.floor((Math.random() * max) + min);
},
// takes an array and returns the array randomly sorted