Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 89acc0d

Browse files
Merge pull request #55 from kruimol/main
Add a random string generator for javascript
2 parents 87f9234 + b31a781 commit 89acc0d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎public/data/javascript.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,19 @@
809809
],
810810
"tags": ["javascript", "sleep", "delay", "utility", "promises"],
811811
"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"
812825
}
813826
]
814827
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /