Created
October 6, 2016 04:06
-
-
Save motss/545b80623660a34d09d3aabdeae3f8eb to your computer and use it in GitHub Desktop.
Generating random number with minNumber and maxNumber inclusive.
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
// Generate random number between 0 and <maxNumber> inclusive. | |
function randomWithRange(minNumber, maxNumber) { | |
var _minNumber = minNumber || 0; | |
var _maxNumber = (maxNumber || 1) * 10 + 1 - _minNumber; | |
var _random = _minNumber + Math.floor(Math.random() * _maxNumber) / 10; | |
return randomWithRange; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment