Math.random()
que gera um número decimal aleatório entre 0
(inclusive) e não chega a 1
(exclusivo). Assim Math.random()
pode retornar um 0
mas nunca retorna um 1
Nota return
executado, para que possamos return
o valor da função Math.random()
. randomFraction
para retornar um número aleatório em vez de retornar 0
. randomFraction
deve retornar um número aleatório.
testString: 'assert(typeof randomFraction() === "number", "randomFraction
should return a random number.");'
- text: O número retornado por randomFraction
deve ser um decimal.
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by randomFraction
should be a decimal.");'
- text: Você deve estar usando Math.random
para gerar o número decimal aleatório.
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using Math.random
to generate the random decimal number.");'
```