mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2025-12-06 09:24:07 +00:00
15 lines
421 B
JavaScript
15 lines
421 B
JavaScript
/**
|
|
* Generates a random string containing numbers and letters
|
|
* @param {number} length The length of the string
|
|
* @return {string} The generated string
|
|
*/
|
|
module.exports = (length) => {
|
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
let text = '';
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
}
|
|
return text;
|
|
};
|