Browse Source

Add getRandomInt to helpers.

painor 5 years ago
parent
commit
f8f5e81497
1 changed files with 13 additions and 0 deletions
  1. 13 0
      utils/Helpers.js

+ 13 - 0
utils/Helpers.js

@@ -112,6 +112,19 @@ class Helpers {
         return shaSum.digest();
         return shaSum.digest();
 
 
     }
     }
+
+    /**
+     * returns a random int from min (inclusive) and max (inclusive)
+     * @param min
+     * @param max
+     * @returns {number}
+     */
+    static getRandomInt(min, max) {
+        min = Math.ceil(min);
+        max = Math.floor(max);
+        return Math.floor(Math.random() * (max - min + 1)) + min;
+    }
+
 }
 }
 
 
 exports.helpers = Helpers;
 exports.helpers = Helpers;