* fix: restructure certifications guide articles * fix: added 3 dashes line before prob expl * fix: added 3 dashes line before hints * fix: added 3 dashes line before solutions
552 B
552 B
title
title |
---|
Generate Random Fractions with JavaScript |
Generate Random Fractions with JavaScript
Solutions
Solution 1 (Click to Show/Hide)
function randomFraction() {
// Only change code below this line.
var result = 0;
// Math.random() can generate 0. We don't want to return a 0,
// so keep generating random numbers until we get one that isn't 0
while (result === 0) {
result = Math.random();
}
return result;
// Only change code above this line.
}