1. 輸出三個(gè)人名:
var student = new Array(3);
student[0] = "張某某";
student[1] = "王某某";
student[2] = "李某某";
for(var i=0;i<3;i++){
? ? document.write("第" + (i+1) + "姓名是:" + student[i] + "<br>");
}
【運(yùn)行結(jié)果】
第1姓名是:張某某
第2姓名是:王某某
第3姓名是:李某某
2. 用數(shù)組形式輸出當(dāng)前時(shí)間恋博,包括星期
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
var date = now.getDate();
var day = now.getDay();
var week = ["日","一","二","三","四","五","六"];
document.write("今天是:" + year + "年" + month + "月" + date + "日" + " 星期" + week[day]);
【運(yùn)行結(jié)果】今天是:2021年5月11日 星期二