--- id: cf1111c1c11feddfaeb9bdef title: Generate Random Fractions with JavaScript challengeType: 1 videoUrl: '' localeTitle: Gerar frações aleatórias com JavaScript --- ## Description
Números aleatórios são úteis para criar um comportamento aleatório. JavaScript tem uma função 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
Assim como Armazenando Valores com o Operador Igual , todas as chamadas de função serão resolvidas antes que o return executado, para que possamos return o valor da função Math.random() .
## Instructions
Altere randomFraction para retornar um número aleatório em vez de retornar 0 .
## Tests
```yml tests: - text: 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.");' ```
## 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 ```