ceil()向上取整与round()逢五进一

    xiaoxiao2021-03-25  77

    取1~5随机数的两种方法: Math.ceil(Math.random()*5) Math.round(Math.random()*(5-1)+1) alert(Math.round(Math.random()*(y-x)+x)); //x~y alert(Math.round(Math.random()*80+20))//20~100 alert(Math.round(Math.random()*10+10))//10~20 alert(Math.round(Math.random()*5+5)) //5~10 alert(Math.round(Math.random()*10))//0~10 alert(Math.round(3.5))
    转载请注明原文地址: https://ju.6miu.com/read-35808.html

    最新回复(0)