1
Zenyk 2020-05-12 16:10:01 +08:00
const random = (min = 0, max = 1, rest = 0) => {
return (Math.random() * max + min).toFixed(rest) } random(1, 3, 2) |
2
VDimos 2020-05-12 16:11:53 +08:00 via Android
toFixed 取小数点后 n 位
|
3
faceRollingKB 2020-05-12 16:15:17 +08:00
function GetRandomNumber(min, max) {
min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; } function YourMethod(min, max){ return GetRandomNumber(min*100, max*100)/100 } |
4
JankinZhang OP @Zenyk 感谢感谢
|
5
JankinZhang OP @VDimos 谢谢啦
|
6
JankinZhang OP @faceRollingKB 感谢大佬
|