Need help with Generate Random Fractions with JavaScript [Solved]

I cannot figure out how to solve this problem. Can someone help me with the code? Here is what I have.

function randomFraction() {

  // Only change code below this line.

  for(var i = 0; i < 1; i-=);  
  return math.random;
}
  

  // Only change code above this line.
}

Is this the answer?

function randomFraction() {

  // Only change code below this line.

   
  return Math.random();



  // Only change code above this line.
 (function(){return myFunction();})();     
}

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

Try it and see :slight_smile:

Why have you included the function call below the comment telling you not to include more code - what did you want that to do?

I tried it and it worked. So, I guess that’s it.

1 Like

No, this is the answer:

function randomFraction() {

// Only change code below this line.

return Math.random();

// Only change code above this line.

}

Please look at the code formatting link above.

1 Like

function randomFraction() {

// Only change code below this line.

var number = Math.random();

return 1.2;

// Only change code above this line.
}

}i fill you should try

function randomFraction() {

// Only change code below this line.

return Math.random();

// Only change code above this line.