Skip to content
Browse files

randomOf

  • Loading branch information...
1 parent 7d6215a commit dc8f36de60e7a22d83334e86c18270574aa9386d @dominictarr committed
Showing with 5 additions and 1 deletion.
  1. +5 −1 random.js
View
6 random.js
@@ -1,6 +1,10 @@
-exports.randomInt = function (min, max) {
+var randomInt = exports.randomInt = function (min, max) {
min = min || 1
max = max || 100
return Math.round(Math.random()*(max - min)) + min
}
+
+exports.randomOf = function (array) {
+ return array[randomInt(0, array.length)]
+}

0 comments on commit dc8f36d

Please sign in to comment.
Something went wrong with that request. Please try again.