|
809 | 809 | ],
|
810 | 810 | "tags": ["javascript", "sleep", "delay", "utility", "promises"],
|
811 | 811 | "author": "0xHouss"
|
| 812 | + }, |
| 813 | + { |
| 814 | + "title": "Random string", |
| 815 | + "description": "Generates a random string of characters of a certain length", |
| 816 | + "code": [ |
| 817 | + "function makeid(length, characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {", |
| 818 | + " return Array.from({ length }, () => characters.charAt(Math.floor(Math.random() * characters.length))).join('');", |
| 819 | + "}", |
| 820 | + "", |
| 821 | + "console.log(makeid(5), \"1234\" /* (optional) */);" |
| 822 | + ], |
| 823 | + "tags": ["javascript", "function", "random"], |
| 824 | + "author": "kruimol" |
812 | 825 | }
|
813 | 826 | ]
|
814 | 827 | },
|
|
0 commit comments