quiz init commit

This commit is contained in:
modeht
2022-04-11 06:32:47 +02:00
commit 3e49e31399
445 changed files with 109700 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
/**
* Generate random code with given length
* @param {Number} length code length
* @returns {String} Generated code
* @example
* generateCode(6)
*/
module.exports = function generateCode(length) {
var result = '';
var characters = '0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
};