function writeDocument(variable){
document.write(variable+"<br/>");
}
writeDocument("生成随机验证码---------");
function generateVerify(length){
var strValue="456789GSDFGHJKL";
var code="";
for(var i=0;i<length;++i){
var randomIndex=Math.floor(Math.random()*strValue.length);
code+=strValue.charAt(randomIndex);
}
return code;
}
writeDocument(generateVerify(4));
writeDocument("找出3,9,12,99,45,78中的最大值和最小值-------");
var a = Math.max(3, 9, 12, 99, 45, 78);
var b = Math.min(3, 9, 12, 99, 45, 78);
document.write("最大值为:" + a + "最小值为:" + b);
writeDocument("请随机生成一个颜色值rgb(X,Y,Z),其中xyz表示的是0~255的数字-------");
function getColor() {
var x = Math.floor(Math.random() * (255+1));
var y = Math.floor(Math.random() * (255+1));
var z = Math.floor(Math.random() * (255+1));
var rgb = "rgb(" + x + "," + y + "," + z + ")";
return rgb;
}
document.write(getColor());
console