(mode, length)
| 404 | } |
| 405 | |
| 406 | function random(mode, length) { |
| 407 | let result = ''; |
| 408 | let chars; |
| 409 | |
| 410 | if (mode == 1) { |
| 411 | chars = 'abcdef1234567890'; |
| 412 | } else if (mode == 2) { |
| 413 | chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; |
| 414 | } else if (mode == 3) { |
| 415 | chars = '0123456789'; |
| 416 | } else if (mode == 4) { |
| 417 | chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 418 | } |
| 419 | for (let i = 0; i < length; i++) { |
| 420 | result += chars[range(0, chars.length-1)]; |
| 421 | } |
| 422 | |
| 423 | return result; |
| 424 | } |
| 425 | |
| 426 | function randomItem(arr) { |
| 427 | return arr[range(0, arr.length-1)]; |
no test coverage detected