Created
February 27, 2014 16:41
-
-
Save wesbos/9253844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Why do we use: | |
Math.floor(Math.random() * 6) + 1; | |
// vs | |
Math.ceil(Math.random() * 6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, the latter could potentially be 0 very rarely, when you wanted 1 through 6.
I just made an app that ran 100 billion times and Math.random was never 0 but formally it could be.