Add utility to generate a random game code.
This commit is contained in:
parent
de8b4a1b62
commit
44782f3e85
1 changed files with 10 additions and 0 deletions
10
src/utils/gamecode.ts
Normal file
10
src/utils/gamecode.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export const generate_game_code = (): string => {
|
||||
let game_code = ``;
|
||||
|
||||
// Generate the game code using the length given
|
||||
do {
|
||||
game_code += Math.floor(Math.random() * 9);
|
||||
} while (game_code.length < 6);
|
||||
|
||||
return game_code
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue