--- id: cf1111c1c11feddfaeb9bdef title: Generate Random Fractions with JavaScript challengeType: 1 videoUrl: '' localeTitle: Generar fracciones aleatorias con JavaScript --- ## Description
Los números aleatorios son útiles para crear un comportamiento aleatorio. JavaScript tiene una función 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
Al igual que el almacenamiento de valores con el operador igual , todas las llamadas de función se resolverán antes de que se ejecute la return , por lo que podemos return el valor de la función Math.random() .
## Instructions
Cambie randomFraction para devolver un número aleatorio en lugar de devolver 0 .
## Tests
```yml tests: - text: 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.");' ```
## Challenge Seed
```js function randomFraction() { // Only change code below this line. return 0; // Only change code above this line. } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```