Last active
July 17, 2016 03:17
-
-
Save lukehedger/7322553 to your computer and use it in GitHub Desktop.
CoffeeScript random number generator
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
_randomNum: (max,min=0) -> | |
return Math.floor(Math.random() * (max - min) + min) | |
# min is set to 0 by default but a different value can be passed to function | |
_randomise: -> | |
randomNum = @_randomNum(10) | |
# returns a random integer between 0 and 10 | |
randomNumAlt = @_randomNum(10,5) | |
# returns a random integer betwen 5 and 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment