Ashraf Nazar fda7fb174e fix: Correct paths in English exercises by prefixing "/" before "learn" (#38099)
* fix: Correct paths in English exercises by prefixing "/" before "learn"

* fix(lang): Correct paths to exercises by prefixing "/" before "learn" in remaining languages
2020-01-26 12:51:21 -06:00

2.2 KiB

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
cf1111c1c11feddfaeb9bdef Generate Random Fractions with JavaScript 1 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

tests:
  - text: <code>randomFraction</code> deve retornar um número aleatório.
    testString: 'assert(typeof randomFraction() === "number", "<code>randomFraction</code> should return a random number.");'
  - text: O número retornado por <code>randomFraction</code> deve ser um decimal.
    testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by <code>randomFraction</code> should be a decimal.");'
  - text: Você deve estar usando <code>Math.random</code> para gerar o número decimal aleatório.
    testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using <code>Math.random</code> to generate the random decimal number.");'

Challenge Seed

function randomFraction() {

  // Only change code below this line.

  return 0;

  // Only change code above this line.
}

After Test

console.info('after the test');

Solution

// solution required