mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-31 15:03:21 -05:00
* fix(curriculum): standradize links in curriculum * Data analiysis links * CIP links * fixed links in s-expressions * Update curriculum/challenges/english/01-responsive-web-design/basic-css/use-hex-code-for-specific-colors.md Co-authored-by: Ilenia <nethleen@gmail.com> * added space before target attribute * standarize external and .rock example links * wrap "check out the projects" around the links Co-authored-by: Ilenia <nethleen@gmail.com>
1.6 KiB
1.6 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| cf1111c1c11feddfaeb9bdef | Generate Random Fractions with JavaScript | 1 | https://scrimba.com/c/cyWJJs3 | 18185 | generate-random-fractions-with-javascript |
--description--
Random numbers are useful for creating random behavior.
JavaScript has a Math.random() function that generates a random decimal number between 0 (inclusive) and 1 (exclusive). Thus Math.random() can return a 0 but never return a 1.
Note: Like Storing Values with the Assignment Operator, all function calls will be resolved before the return executes, so we can return the value of the Math.random() function.
--instructions--
Change randomFraction to return a random number instead of returning 0.
--hints--
randomFraction should return a random number.
assert(typeof randomFraction() === 'number');
The number returned by randomFraction should be a decimal.
assert((randomFraction() + '').match(/\./g));
You should be using Math.random to generate the random decimal number.
assert(code.match(/Math\.random/g).length >= 0);
--seed--
--after-user-code--
(function(){return randomFraction();})();
--seed-contents--
function randomFraction() {
// Only change code below this line
return 0;
// Only change code above this line
}
--solutions--
function randomFraction() {
return Math.random();
}