Generate Random Whole Numbers with JavaScript...something is missing

Hi,

I wonder what is wrong with my code. Everything seems to be right except one thing: “The result of randomWholeNum should be a whole number.”

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.
  Math.floor(Math.random() * 10);
  return Math.random();
}

Look closely what are you returning from function :slight_smile:

1 Like

I tried return Math.floor(); and then I tried return randomWholeNum(); but they don’t work.

With a slight change…

1 Like

Thank you. Now it worked. But why it did not work with return randomWholeNum(); ?

You would create an infinate loop.

1 Like