diff --git a/src/utils/helpers/stringHelpers.js b/src/utils/helpers/stringHelpers.js new file mode 100644 index 0000000..8f7dab0 --- /dev/null +++ b/src/utils/helpers/stringHelpers.js @@ -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; +}