Task:
1. Get the current date through the built-in object of JS
var date=new date ();
var year=date.tostring (). Slice (11,15);
document.write (year.tostring () + "year");
var month=date.getmonth ();
month=month+1;
if (month<10) {
document.write ("0" +month+ "month");
} else{
document.write (month+ "Month");
}
var day=date.tostring (). Slice (8,10);
document.write (day+ "Day");
var weekday=["Day", "one", "two", "three", "four", "five", "six"];
var week=date.getday ();
document.write ("Week" +weekday[week]);
2. Better operation of the string in an array
var scorestr = "Xiao Ming: 87; Floret: 81; Xiao Hong: 97; Little day: 76; little Zhang: 74; small: 94; Xiao XI: 90; Xiao Wu: 76; Dicky: 64; Xiaoman:";
var scorearr=scorestr.split (";");
3. Rub the score out of the array, sum the whole and output
function Getnum (str) {
var str1=str.replace (/[*0-9]/ig, "");
Return Str.replace (STR1, "");
}
var num=0, Len=scorearr.length;
for (Var i=0;i<len;i++) {
var num1=getnum (Scorearr[i]);
Num+=number (NUM1);
}
Num=parseint (Num/len);
document.write ("--the average class is divided into:" +num);
Here's my chart of effects:
The above is small series for everyone to bring the JS built-in object processing _ print student transcript of the simple realization of all the content, hope to help you, a lot of support cloud Habitat Community ~