@c_s_v_s_subrahmanyam/string-utils
Version:
A comprehensive utility library for advanced string operations.
14 lines (12 loc) • 418 B
JavaScript
// String repetition
module.exports = {
repeatString: (str, times) => str.repeat(times),
generateCaptcha: (length = 6) => {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let captcha = '';
for (let i = 0; i < length; i++) {
captcha += chars.charAt(Math.floor(Math.random() * chars.length));
}
return captcha;
},
};