A class of results come out, now the teacher to the class of results printed out.
:
XXXX year XX month x Day week x--class Total is divided into: 81
Format requirements:
1. Display the date of printing. The format is similar to the current time of "xxxx year XX month XX day week X".
2. Calculate the average (reserved integer) of the class.
Student performance data are as follows:
"Xiao Ming: 87; Floret: 81; Little Red: 97; Small day: 76; Xiao Zhang: 74; little: 94; Xiao XI: 90; Xiao Wu: 76; Dicky: 64; Small ord: 76 "
Task
The first step: you can get the current date by using JavaScript's Date object.
Tip: Use Date () Dates object, note that the week return value is 0-6, so you want to turn the word "Week X"
The second step: a long-channeling string is not good, find the rule after the division into the array to better operate OH.
Step three: Divide the string to get the score, then sum the rounding.
Tip: The parseint () string type is converted to an integral type.
<! DOCTYPE html>//get the current date by using the JavaScript Date object and output. varMydate=NewDate (); //The result is a long-channeling string bad processing, find the rule after the split into the array better operation Oh varScorestr = "Xiao Ming: 87; Floret: 81; Little red: 97; Small day: 76; Xiao Zhang: 74; little: 94; Xiao XI: 90; Xiao Wu: 76; Dicky: 64; Small ord: 76"; varArr=scorestr.split (': ')); //Extract the scores from the array, then sum them up and output them. varSum=0; for(vari=0;i<arr.length;i++) { if(i%2) {sum+=parseint (Arr[i]); document.write (parseint (arr[i])+ "<br>"); }} document.write (sum); </script>JS extracts numbers from an array