Skip to content

Instantly share code, notes, and snippets.

@suhaboncukcu
Forked from ccorcos/gist:11129592
Last active August 29, 2015 14:14
Show Gist options
  • Save suhaboncukcu/6a1091fd634df40f5a23 to your computer and use it in GitHub Desktop.
Save suhaboncukcu/6a1091fd634df40f5a23 to your computer and use it in GitHub Desktop.
randomInRange = function(min, max) {
var random = Math.floor(Math.random() * (max - min + 1)) + min;
return random;
}
randomFromCollection = function(C) {
return function() {
c = C.find().fetch();
i = randomInRange(0, c.length); //c.count() is not valid in meteor 1.0.2.1 since this is an array now.
return c[i]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment