Process Control for Loop +if Judging +math Object +array object +date object making score table
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> Comprehensive use </title>
<style type= "Text/css" >
Body {
Text-align:center;
font:14px "Microsoft Jas Black";
}
TD {
padding:8px 10px;
}
Table {
Display:inline-block;
border:5px solid #6495ED;
}
Caption {
background-color: #6495ED;
Color:white;
padding:10px 5px;
}
</style>
<body>
<!--
Summation Formula
var sum = 0;
For (Var i=0;i<myarr.length;i++) {
sum + = myarr[i][1];
//alert (myarr[i][1]);
//document.write (myarr[i][0]+ ' <br/> ');
}
//document.write (sum);
document.getElementById (' Sum '). innerText = sum;
Find Average
var pjf = sum/myarr.length;
document.getElementById (' B '). InnerHTML = Math.Round (PJF);
Other small experiments that are immature and unsuccessful.
//document.getelementbyid (' B '). InnerText = Math.Round (math.sqrt (sum));//rounding (arithmetic square root (sum and value))//document.write ( Math.pow (math.sqrt (sum), 2));-->
<script type= "Text/javascript" >
//Score Information
var myarr = [
[' xiaoming ',]
[' Floret ', Bayi],
[' Little Red ',
[' Small Day ',],
[' Xiao Zhang ', Wu Si],
[' Little ', 94],
[' Xiao Xi ', []
[' Little Dance ', []
[' Little Dee ', [],
[' Little Mann ',
];
//month
var month = [1, 2, 3, 4, 5, 6, 7, 8, 9, ten, one, one];
//week
var day = [' Sunday ', ' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday '];
var mydate = new Date ();//var year = Mydate.getfullyear ();
Date
var Datearr = [Mydate.getfullyear () + ' year ', Month[mydate.getmonth ()] + ' month ', mydate.getdate () + ' Day ', Day[mydate.getday ()];
//Total
var sum = 0;//This must be defined as 0, which is also the way to declare that sum is a numeric value, otherwise the direct Var sum. Will return Nan, not a numeric value
For (var s = 0; s < myarr.length; s++) {
sum + = parseint (myarr[s][1]);
//alert (myarr.length);
//alert (myarr[s][1]);
}
//alert (sum);
//average-equal to total score divided by class size
var pjf = sum/myarr.length;
//document.write (sum);
//document.write (PJF);
//finally added separately:
Myarr.push ([' Total score ', sum], [' average ', PJF]);
//Start writing forms
document.write (' <table border= ' 1 ' > ');
document.write (' <caption>181 Class final results Table </caption> ');
document.write (' <tr> ');
For (var a = 0; a < datearr.length; a++) {
document.write (' <td> ' + datearr[a] + ' </td> ');
}
document.write (' </tr> ');
for (var i = 0; i < myarr.length; i++) {//Implementation write 10 lines
document.write (' <tr> ');
For (var j = 0; J < 1; j + +) {//write once per line
document.write (' <td> ' + myarr[i][0] + ' </td> ');//The first cell in the
document.write (' <td> ' + myarr[i][1] + ' </td> ');//The second cell in the
if (i < myarr.length-2) {//Throw away the last two not to be judged, because the last two are separately added to the total score for peaceful sharing. Therefore, only if I is less than the length minus the last two after the case can be judged.
if (myarr[i][1] >= 80) {//write notes after judging scores
document.write (' <td> excellent </td> ');
} else if (Myarr[i][1] < && myarr[i][1] >=) {
document.write (' <td> pass </td> ');
} else {
document.write (' <td> </td> ');
}
}
Alert (Myarr[j]);
}
document.write (' </tr> ');
}
document.write (' </table> ');
alert (myarr.length);
alert (myarr[i].length);
</script>
</body>
js-Pure JS Production Dynamic score table (flow control statement +js built-in object)