# Basic - Generating random number between 0-9

Tell us what’s happening:
The goal of the assignment is to generate random number using Math.random() x whole number between 0-9 (i.e 0 and 9 shouldn’t be generated)

So my initial solution was as follows:

function randomWholeNum() {

return Math.floor(Math.random()*9);
}

However, the requirement stated that I should be multiplying by 10.
Since, 0< Math.random<1,
(multiplying by 10):

0<math.Random x 10< 10 (i.e. 9.99999999 is one of the possible random float)

Followed by rounding down to nearest whole number.
0< math.floor(math.Floor x 10 ) =< 9

Hence, wouldn’t it infringe on the desired condition of generating any random number between 0 and 9?

Many thanks in advance.

Your code so far

``````
function randomWholeNum() {

// Only change code below this line

return Math.floor(Math.random()*10);
}

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36`.

Challenge: Generate Random Whole Numbers with JavaScript

Link to the challenge:

it says that with 20 you get a random number between 0 and 19 included

Remember that `Math.random()` can never quite return a `1` and, because we’re rounding down, it’s impossible to actually get `20` . This technique will give us a whole number between `0` and `19` .

it wants you to do the same with a number between 0 and 9

I think the wording of the challenge could be improved to explicitly say that 0 and 9 should be included.

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.