vendredi 19 juin 2020

How to Generate Random numbers in Javascript based on the provided range Minimum and Maximum characters

I have a bit weird requirement where I need to generate Random numbers of the length that is given by user. User can give Minimum Length and the Maximum Length and I need to generate the random numbers which consist of the character length between this range.

For example if the Minimum Length is 6 and Maximum Length is 10 then I need to generate the random numbers whose number of characters has to be between the range 6 and 10. For this example following can be the random generators:

123456,
7654321,
12345678,
987654321,
5432109876, etc.

Like this the Random generators has to contain the length which is between the provided inputs.

I know how to create random numbers between a range and based on fixed character length but I don't know how to created based on variable length. I tried finding the answers but most of them are based on the fixed length and fixed range, could not find the exact match that I am looking for.

It would be really great if someone can help me with this.




Aucun commentaire:

Enregistrer un commentaire