Skip to content

Instantly share code, notes, and snippets.

@BenBals
Last active March 25, 2016 20:08
Show Gist options
  • Save BenBals/523660074ffe47a3de66 to your computer and use it in GitHub Desktop.
Save BenBals/523660074ffe47a3de66 to your computer and use it in GitHub Desktop.
Random number in JS
random = function(from, to) {return Math.floor((Math.random() * to) + from);};
@BenBals
Copy link
Author

BenBals commented Aug 25, 2014

Coffee version:

random = (from, to) -> Math.floor((Math.random() * to) + from)

ES2015 version:

random = (from, to) => Math.floor((Math.random() * to) + from)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment