时间:2021-07-01 10:21:17 帮助过:4人阅读
/**
* 返回一个随机的小写字母
*/
function getLowerCharacter(){
return getCharacter("lower");;
}
/**
* 返回一个随机的大写字母
*/
function getUpperCharacter(){
return getCharacter("upper");;
}
/**
* 返回一个字母
*/
function getCharacter(flag){
var character = "";
if(flag === "lower"){
character = String.fromCharCode(Math.floor( Math.random() * 26) + "a".charCodeAt(0));
}
if(flag === "upper"){
character = String.fromCharCode(Math.floor( Math.random() * 26) + "A".charCodeAt(0));
}
return character;
}