Please can anyone guide me that is this solution is right or something wrong?

I run this solution and this worked! Is there any expert that tell me about this is a right way or not, please.
Here is the Link:

function randomFraction() {

  // Only change code below this line
  if (Math.random() > 0) {
    return Math.random() * 0.5;
  } else {
  return 0;

  // Only change code above this line

var ans = randomFraction(10);

Please post a link to the challenge you were attempting.

Here is the Link:

Thanks for posting.

I think your code is more than was needed.

Try rewriting it into one line only.

here is a hint to how it should start:

return Math.random(…

please read challenge again see what is returned by Math.random()
0 <= Math.random() < 1
so if you multiply it by 0.5 it will always be a fraction.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.