UNPKG

xe-utils

Version:

JavaScript 函数库、工具类

13 lines (11 loc) • 394 B
import helperMathRound from './helperMathRound.js';/** * 获取一个指定范围内随机数 * * @param {Number} minVal 最小值 * @param {Number} maxVal 最大值 * @return {Number} */ function random (minVal, maxVal) { return minVal >= maxVal ? minVal : ((minVal = minVal >> 0) + helperMathRound(Math.random() * ((maxVal || 9) - minVal))) } export default random