Need help with Generate Random Fractions with JavaScript [Solved]

Need help with Generate Random Fractions with JavaScript [Solved]
0.0 0

#1

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.
}

#2

Is this the answer?

function randomFraction() {

  // Only change code below this line.

   
  return Math.random();



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

#3

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


#4

Try it and see :slight_smile:


#5

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


#6

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


#7

No, this is the answer:

function randomFraction() {

// Only change code below this line.

return Math.random();

// Only change code above this line.

}


#8

Please look at the code formatting link above.


#9

function randomFraction() {

// Only change code below this line.

var number = Math.random();

return 1.2;

// Only change code above this line.
}


#10

}i fill you should try

function randomFraction() {

// Only change code below this line.

return Math.random();

// Only change code above this line.