(mode, length)
| 378 | } |
| 379 | |
| 380 | function random(mode, length) { |
| 381 | let result = ''; |
| 382 | let chars; |
| 383 | |
| 384 | if (mode == 1) { |
| 385 | chars = 'abcdef1234567890'; |
| 386 | } else if (mode == 2) { |
| 387 | chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; |
| 388 | } else if (mode == 3) { |
| 389 | chars = '0123456789'; |
| 390 | } else if (mode == 4) { |
| 391 | chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 392 | } |
| 393 | for (let i = 0; i < length; i++) { |
| 394 | result += chars[range(0, chars.length-1)]; |
| 395 | } |
| 396 | |
| 397 | return result; |
| 398 | } |
| 399 | |
| 400 | function randomItem(arr) { |
| 401 | return arr[range(0, arr.length-1)]; |
no test coverage detected