Created
October 17, 2018 06:05
-
-
Save ssdemajia/2680979dced6ed043686b4fd6349d210 to your computer and use it in GitHub Desktop.
Javascript 小函数~
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
function getRandom(low, up) { | |
// 获得包括low和up范围内的随机整数 | |
var nums = up - low + 1; | |
return Math.floor(Math.random() * nums + low); // Math.floor向下取整 , 2.6 = 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment