I want to generate a random number between 1,000 and 9,999 and convert the return value to string. Thus I have:
(Math.floor(Math.random() * 9999) + 1000).toString()
However, this always returns me a number that starts with one. What am I doing wrong? Also, if I want to return a number where the digits are not repeated and the range is from 1 to 9999, how do I modify the equation?
A random number that didn't begin with a 1.
Aucun commentaire:
Enregistrer un commentaire