function writeDocument(variable){
document.write(variable + "<br/>");
}
writeDocument("最大值最小值---------")
writeDocument("最大值:"+Math.max(1,3,9,19,999));
writeDocument("最小值:"+Math.min(1,3,9,19,999));
writeDocument("生成随机验证码----------")
function generateVerifyCode(length){
var strLetterNumber = "0123456789ABCDEFGHIJKLMNOPQRST";
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(generateVerifyCode(4));
writeDocument(generateVerifyCode(5));
writeDocument(generateVerifyCode(6));
writeDocument("生成随机的颜色 rgb(255,255,255)----------")
function getRandomColor(){
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;
}
document.write(getRandomColor());
耀耀:
function writeDocument(variable){
document.write(variable + "<br/>");
}
document.write('定义一个时间对象----------------<br/>');
var oToday = new Date();
document.write(oToday + "<br/>");
document.write('获取时间对象的年,月,日,时,分,秒----------------<br/>');
document.write("年:"+oToday.getFullYear() + "<br/>");
document.write("月:"+(oToday.getMonth()+1) + "<br/>");
document.write("日:"+oToday.getDate() + "<br/>");
document.write("时:"+oToday.getHours() + "<br/>");
document.write("分:"+oToday.getMinutes() + "<br/>");
document.write("秒:"+oToday.getSeconds() + "<br/>");
document.write('设置时间对象的年,月,日,时,分,秒(2019-6-1 15:59:59:99)---------<br/>');
var oMyBirthday = new Date();
oMyBirthday.setFullYear(2019);
oMyBirthday.setMonth(6);
oMyBirthday.setDate(1);
oMyBirthday.setHours(15);
oMyBirthday.setMinutes(59);
oMyBirthday.setSeconds(59,99);
document.write(oMyBirthday + "<br/>");
document.write('获取星期几-------------<br/>');
document.write("今天是星期"+oToday.getDate() + "<br/>");
var week =["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];
document.write("今天是"+week[oToday.getDay()] + "<br/>");
document.write("请你打印" + "<br/>");
console