Skip to content

Instantly share code, notes, and snippets.

@rootical
Forked from lukehedger/randomNumber.coffee
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rootical/969178e277a9615e0461 to your computer and use it in GitHub Desktop.
Save rootical/969178e277a9615e0461 to your computer and use it in GitHub Desktop.
_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