Created
August 15, 2023 18:02
-
-
Save space11/baee5092215534bc3a9eda3324c83d81 to your computer and use it in GitHub Desktop.
Generates random number of digits of given length.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function generateRandomNumber(length: number): number { | |
| return parseInt( | |
| Math.ceil(Math.random() * Date.now()) | |
| .toPrecision(length) | |
| .toString() | |
| .replace('.', ''), | |
| 10 | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment