Math.floor(Math.random() + 0.5)
Math.random()的取值范围是:
0<=Math.random()<1 随机小数
Math.floor(X) =X的整数位例如Math.floor(6.999) === 6Math.floor(39.001) === 39Math.floor(8) === 8
微信小程序生成随机数 0或者1 js代码
原文:https://www.cnblogs.com/lsyy2017/p/11704769.html