Math.random()
用来生成一个在0
(包括 0)到1
(不包括 1)之间的随机小数,因此Math.random()
可能返回 0 但绝不会返回 1。
提示return
执行之前解析,因此我们可以返回Math.random()
函数的值。
randomFraction
使其返回一个随机数而不是0
。
randomFraction
应该返回一个随机数。
testString: assert(typeof randomFraction() === "number");
- text: randomFraction
应该返回一个小数。
testString: assert((randomFraction()+''). match(/\./g));
- text: 需要使用Math.random
生成随机的小数。
testString: assert(code.match(/Math\.random/g).length >= 0);
```