Skip to content

Instantly share code, notes, and snippets.

@dondevi
Last active March 8, 2018 04:09
Show Gist options
  • Save dondevi/430633144c895f9127adf861b162bcbe to your computer and use it in GitHub Desktop.
Save dondevi/430633144c895f9127adf861b162bcbe to your computer and use it in GitHub Desktop.
Get Random Integer In Range.
/**
* 在指定范围内获取随机整数
* @param {Number} min - 最小值
* @param {Number} max - 最大值
* @return {Number}
*/
function getRandomIntInRange (min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment