Skip to content

Commit cd10c25

Browse files
committed
Add a random string generator for javascript
This function add a random string generator with a certain length
1 parent 6c98606 commit cd10c25

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

public/data/javascript.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,20 @@
798798
],
799799
"tags": ["color", "hex", "contrast", "brightness", "utility"],
800800
"author": "yaya12085"
801+
},
802+
{
803+
"title": "Random string",
804+
"description": "Generates a random string of characters of a certain length",
805+
"code": [
806+
"function makeid(length) {",
807+
" const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';",
808+
" return Array.from({ length }, () => characters.charAt(Math.floor(Math.random() * characters.length))).join('');",
809+
"}",
810+
"",
811+
"console.log(makeid(5));"
812+
],
813+
"tags": ["javascript", "function", "random"],
814+
"author": "kruimol"
801815
}
802816

803817
]

0 commit comments

Comments
 (0)