Requirements: 1, display the date of printing. The format is similar to the current time of Wednesday, March 21, 2014.
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 "
The first thing to know is the use of date objects and return functions
Then there is a little problem, we must carefully look at the description of the functions, a lot of errors is the function declaration did not look carefully,
If the SUBSTRING function terminates position in line 30, remember to add 1!!
If the Spit function of the 19 row is separated, the returned itself is an array!!
1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> Fasten your seat belts and set sail </title>6 7<script type= "Text/javascript" >8 9 //get the current date by using the JavaScript Date object and output. Ten varMydata=NewDate (); One varweeks=NewArray ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); A //document.write (mydata.getfullyear () + "Year" +mydata.getmonth () + "month" +mydata.getdate () + "Day" + "" +weeks (Mydata.getday ( )) + "<br>"); -document.write (Mydata.getfullyear () + "year" + (Mydata.getmonth () +1) + "month" +mydata.getdate () + "Day" +weeks[mydata.getday ()]+ "<br>"); - the - - //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"; + varScorearr=scorestr.split (";"); - //document.write (Scorearr); + A at - - //take the scores out of the array, and then sum the whole, - varSum=0; - for(vari=0;i<scorearr.length;i++) - { in //Sum+=parseint (Scorearr[i].substr (3,2)); -Sum=sum+parseint (scorearr[i].substring (3,5)); to } + //document.write (sum); -document.write ("Average score is:" +math.round (Sum/scorearr.length)) the</script> * $<body>Panax Notoginseng</body> - JS Learning Web 7-23 Programming practice about string arrays