orchidmap-front/backend/utils/gen.js
2018-11-29 16:18:02 +07:00

10 lines
300 B
JavaScript

module.exports.genRandomSequence = (length = 16) => {
let sequence = '';
const symbols = 'ABCDEFGHIJKLMOPQRSTUVXYZabcdefghijgmlopqrstuvxyz01234567890'
for (let i = 0; i < length; i += 1) {
sequence += symbols[parseInt(Math.random() * (symbols.length - 1), 10)];
}
return sequence;
};