SOURCE

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中的最大值和最小值-------------");
var max=Math.max(3,9,12,99,45,78);
writeDocument("max="+max);
var min=Math.min(3,9,12,99,45,78);
writeDocument("min="+min);


writeDocument("请写一个随机生成颜色值rgb(X, Y, Z)的函数,其中X,Y,Z表示的是0~255的数字---------------"); 
function rgbcolor(){
    var r=Math.floor(Math.random()*256);
    var g=Math.floor(Math.random()*256);
    var b=Math.floor(Math.random()*255);
    return rgb="rgb("+r+','+g+','+b+")";
}
writeDocument (rgbcolor());
console 命令行工具 X clear

                    
>
console