var flip = Math.floor(Math.random()*(1 - 0 + 1))+ 0;?

时间:2015-09-11 22:17:26

标签: javascript

我找到了一些代码段,我不确定它是什么意思:

var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;

Math.floor(Math.random() * (max - min + 1)) + min

我仍然熟悉Javascript ...有人可以给我一个读者摘要缩写版本吗?

1 个答案:

答案 0 :(得分:0)

Math.floor()向下舍入数字到最接近的整数

例如:如果您有2.7,它将向下舍入为2.

Math.random()返回0到1之间的随机数

例如:.693