Here we will be generating the random number of 9 digits using JS.
function getRandom(length) {
return Math.floor(Math.pow(10, length-1) + Math.random() * 9 * Math.pow(10, length-1));
}
getRandom(9)
Output:
234664534
Here we will be generating the random number of 9 digits using JS.
function getRandom(length) {
return Math.floor(Math.pow(10, length-1) + Math.random() * 9 * Math.pow(10, length-1));
}
getRandom(9)
Output:
234664534
For further actions, you may consider blocking this person and/or reporting abuse
cn-2k -
Code Boxx -
Muhammad Bilal -
Valentin BEGGI -
Once suspended, chauchausoup will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, chauchausoup will be able to comment and publish posts again.
Once unpublished, all posts by chauchausoup will become hidden and only accessible to themselves.
If chauchausoup is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Krishna Dhakal.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag chauchausoup:
Unflagging chauchausoup will restore default visibility to their posts.
Top comments (3)
Very cool approach! I noticed that you disallowed leading zeros, and I think that's a good choice because the function returns a number, not a string, and leading zeros would be ignored anyway. The only time I think a zero might be expected as the first digit would be when calling
getRandom(1)
. You might expect0
to be a possible result then, but it's not currently.Love the function; very creative.
Hello friends its my first blog in this platform. I was trying to go with netlify for static site generation but I thought dev community is benificial for me to learn and communicate with fellow dev friends.
Yes, well come you! You can let the func more useful by adding the condition to passing the autotest.