Created
October 23, 2013 06:53
-
-
Save yuezk/7113724 to your computer and use it in GitHub Desktop.
得到指定数字之间的随机数,来自《JavaScript高级程序设计》
This file contains hidden or 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 selectFrom(lowerValue, upperValue) { | |
var choices = upperValue - lowerValue + 1; | |
return Math.floor(Math.random() * choices + lowerValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment