(length = 6)
| 205 | } |
| 206 | |
| 207 | function generateRandomCode(length = 6) { |
| 208 | const min = Math.pow(10, length - 1); // Minimum number for the given length |
| 209 | const max = Math.pow(10, length) - 1; // Maximum number for the given length |
| 210 | return Math.floor(Math.random() * (max - min + 1)) + min; |
| 211 | } |
| 212 | |
| 213 | const code = generateRandomCode(); |
| 214 |