前端面试常考题(JavaScript)

tech2022-07-06  217

使用math对象生成一个1到100之间的随机数。 Math.random() 为0到1之间的随机数(包括0,不包括1)[0, 1) Math.round(n) 为n四舍五入后的整数 Math.ceil(n) 为大于等于n的最小整数 Math.floor(n) 为小于等于n的最大整数 console.log(Math.floor(Math.random() * 100) + 1);
最新回复(0)