Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created January 6, 2012 08:30
Show Gist options
  • Select an option

  • Save psiborg/1569702 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/1569702 to your computer and use it in GitHub Desktop.
JS Prototype - randomFromTo
if (!Math.prototype.randomFromTo) {
Math.prototype.randomFromTo = function (lo, hi) {
return Math.round(Math.random() * (hi - lo)) + lo; // dilate then translate
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment