numcode
Version:
6️⃣7️⃣ Generating codes is easy and simple.
19 lines (18 loc) • 439 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Create number code with length option.
* @param length Length of code
* length from 4 to 6.
*/
function numcode(length = 4) {
if (length < 4 || length > 6) {
length = 4;
}
let result = '';
for (let i = 0; i < length; i++) {
result += Math.floor(Math.random() * 10);
}
return result;
}
exports.numcode = numcode;
;