add string helpers
This commit is contained in:
parent
28719eb898
commit
2b9dbd0e83
16
src/utils/helpers/stringHelpers.js
Normal file
16
src/utils/helpers/stringHelpers.js
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Returns a randomly generated string with the specified length
|
||||
*
|
||||
* @param {Number} length
|
||||
* @returns The random string
|
||||
*/
|
||||
function randomString(length) {
|
||||
var result = "";
|
||||
var characters =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var charactersLength = characters.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user