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

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

                    
>
console