As the title says … is it possible to create a random 16 digit number with jquery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just use:
EDIT :
Note that there is about a 1/10 chance of a lower number of digits. If
Math.random()generates something like0.0942104924071337then0.0942104924071337 * 1E16is0942104924071337which evaluates to942104924071337; a 15 digit number.The only way to 100% guarantee that the number is 16 digits in length is to have it be formed as a string. Using this method I would recommend @rjmunro’s answer: