function writeDocument(variable) {
document.write(variable + "<br/>");
}
writeDocument("生成随机验证码------------------");
function generateVerifyCode(length) {
var strValue = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var code = "";
for (var i = 0; i < length; ++i) {
var randomIndex = Math.floor(Math.random() * strValue.length);
code += strValue.charAt(randomIndex);
}
return code;
}
writeDocument(generateVerifyCode(4));
writeDocument(generateVerifyCode(5));
writeDocument(generateVerifyCode(6));
writeDocument("用Math的方法找出3, 9, 12, 99, 45, 78中的最大值和最小值-------------");
writeDocument("最大值:" + Math.max(3, 9, 12, 99, 45, 78));
writeDocument("最小值:" + Math.min(3, 9, 12, 99, 45, 78));
writeDocument("请写一个随机生成颜色值rgb(X, Y, Z)的函数,其中X,Y,Z表示的是0~255的数字---");
function generateRadomColor() {
var red = Math.floor(Math.random() * 256);
var blue = Math.floor(Math.random() * 256);
var green = Math.floor(Math.random() * 256);
writeDocument("rgb("+ red + "," + blue + "," + green + ")");
}
generateRadomColor();
generateRadomColor();
console