Math.random()
que genera un número decimal aleatorio entre 0
(incluido) y no hasta 1
(exclusivo). Por Math.random()
tanto, Math.random()
puede devolver un 0
pero nunca devolver una 1
Nota return
, por lo que podemos return
el valor de la función Math.random()
. randomFraction
para devolver un número aleatorio en lugar de devolver 0
. randomFraction
debería devolver un número aleatorio.
testString: 'assert(typeof randomFraction() === "number", "randomFraction
should return a random number.");'
- text: El número devuelto por randomFraction
debe ser un decimal.
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by randomFraction
should be a decimal.");'
- text: Debería estar usando Math.random
para generar el número decimal aleatorio.
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using Math.random
to generate the random decimal number.");'
```