"JS Learning" web 7-23 programming exercises about string arrays

Source: Internet
Author: User
Tags ming ord

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.