Skip to content

Instantly share code, notes, and snippets.

@yuezk
Created October 23, 2013 06:53
Show Gist options
  • Save yuezk/7113724 to your computer and use it in GitHub Desktop.
Save yuezk/7113724 to your computer and use it in GitHub Desktop.
得到指定数字之间的随机数,来自《JavaScript高级程序设计》
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