The Math.randon () and date objects of this section mainly refer to a date instance and a Math.rando function instance.
Extract an example of information from a Date object
<script language= "Web Effects" type= "Text/javascript" >
<!--
var objdate=new date ();//Create a Date object representing the current time
var year=objdate.getfullyear ();
var month=objdate.getmonth () +1; The month that GetMonth returns is starting from 0, so it's going to add 1.
var date=objdate.getdate ();
var day=objdate.getday ();
Determines, based on the index of the number of weeks, that the text represents
Switch (day) {
Case 0:
Day= "Sunday";
Break
Case 1:
Day= "Monday";
Break
Case 2:
Day= "Tuesday";
Break
Case 3:
Day= "Wednesday";
Break
Case 4:
Day= "Thursday";
Break
Case 5:
Day= "Friday";
Break
Case 6:
Day= "Saturday";
Break
}
document.write ("Today is:" +year+ "year" +month+ "month" +date+ "Day "+day);
-->
</script>
Using the Random function Math.randon () example
<script language= "javascript" type= "Text/javascript"
<!--
var totalcount=10000;
var okcount=0;
for (Var i=0;i<totalcount;i++) {
var p1=math.random (); //get first breakpoint
var p2=math.random () ; //gets the second breakpoint
var s1=math.min (P1,P2) //gets the first segment length
var s2=math.max (P1,P2)-s1; // Get the second paragraph length
var s3=1-s1-s2; //Get the third paragraph length
if (s1>=0.5 | | s2>=0.5 | | s3>= 0.5) continue; //as long as one side is longer than 0.5, the triangle cannot be formed
okcount++;
Alert (okcount/totalcount);
//-->
</script>