/
document.write(Math.PI+"
");
document.write(Math.random()+"
");
document.write(Math.round(3.14)+"
");
document.write(Math.ceil(3.14)+"
");
document.write(Math.floor(3.14)+"
");
/
- 取1-100之间的随机整数
-
1. Math.random()产生随机数 范围[0,1)小数
-
2. 乘以100 ---> [0,99,9999] 小数
-
3. 舍弃小数部分 floor --> (0,99]整数
-
4. +1 -->
- */
var number=Math.floor( Math.random()*100)+1;
document.write(number);