Created
December 16, 2021 08:04
-
-
Save Lobbyra/2b4d81f92ab65219d505667ce19c9753 to your computer and use it in GitHub Desktop.
sample code to test generateCode, part of auth_nest_template
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 generateCode(): number { | |
| var draw: number = Math.random(); | |
| draw *= Math.pow(10, 6); | |
| while (draw < 100000) { | |
| draw *= 10; | |
| } | |
| return (Math.round(draw)); | |
| } | |
| var test: number; | |
| for (var i = 0; i < 1000; i++) { | |
| test = generateCode(); | |
| if (test < 100000 || test > 999999) | |
| throw 'test = ' + test.toString(); | |
| else | |
| console.log(test); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment