Skip to content

Instantly share code, notes, and snippets.

@Lobbyra
Created December 16, 2021 08:04
Show Gist options
  • Select an option

  • Save Lobbyra/2b4d81f92ab65219d505667ce19c9753 to your computer and use it in GitHub Desktop.

Select an option

Save Lobbyra/2b4d81f92ab65219d505667ce19c9753 to your computer and use it in GitHub Desktop.
sample code to test generateCode, part of auth_nest_template
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