function writeDocument(variable) {
document.write(variable + "<br/>");
}
writeDocument("最大值最小值-------------------------")
writeDocument("最大值" + Math.max(1,3,8,10,18,9));
writeDocument("最小值" + Math.min(1,3,8,10,18,9));
writeDocument("生成4位随机验证码-------------------------")
function generateVerfyCode(length){
var strLetterNumber = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var code = "";
for(var i = 0;i < length; ++i){
var randomNumber = Math.floor(Math.random() * strLetterNumber.length);
code = code + strLetterNumber.charAt(randomNumber);
}
return code;
}
writeDocument(generateVerfyCode(4));
writeDocument(generateVerfyCode(5));
writeDocument(generateVerfyCode(6));
writeDocument("生成随机颜色 RGB(255,255,255)-------------------------")
function getColor() {
var r = Math.floor(Math.random() * (255 + 1));
var g = Math.floor(Math.random() * (255 + 1));
var b = Math.floor(Math.random() * (255 + 1));
var rgb = "rgb(" + r + "," + g + "," + b + ")";
return rgb;
}
writeDocument(getColor());
console