Basic Javascript - Generate Random Fractions with JavaScript

Basic Javascript - Generate Random Fractions with JavaScript
0

#1

Tell us what’s happening:

why am I not seeing a random number? I also copied and pasted the code into repl.it and I’m getting an undefined message?

Your code so far


function randomFraction() {

  // Only change code below this line.
var result = 0;
while (result === 0){

result = Math.random();
}
  return result;

  // Only change code above this line.
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/generate-random-fractions-with-javascript


#2

It works fine, in repl.it too


#3

Thank you, I wasn’t calling the function. Dah!