Math.random()函数,它生成一个介于0 (含)和不高达1 (独占)之间的随机十进制数。因此Math.random()可以返回0但永远不会返回1 Note return执行之前解析,因此我们可以return Math.random()函数的值。 randomFraction以返回随机数而不是返回0 。 randomFraction应该返回一个随机数。
testString: 'assert(typeof randomFraction() === "number", "randomFraction should return a random number.");'
- text: randomFraction返回的randomFraction应该是小数。
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by randomFraction should be a decimal.");'
- text: 您应该使用Math.random来生成随机十进制数。
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using Math.random to generate the random decimal number.");'
```