Math.random()
function that generates a random decimal number between 0
(inclusive) and not quite up to 1
(exclusive). Thus Math.random()
can return a 0
but never quite return a 1
Notereturn
executes, so we can return
the value of the Math.random()
function.
randomFraction
to return a random number instead of returning 0
.
randomFraction
should return a random number.
testString: assert(typeof randomFraction() === "number");
- text: The number returned by randomFraction
should be a decimal.
testString: assert((randomFraction()+''). match(/\./g));
- text: You should be using Math.random
to generate the random decimal number.
testString: assert(code.match(/Math\.random/g).length >= 0);
```