<script>/*Math object: Math*/ with(document) {Write (' Absolute value of <br>-3.5: ' +math.abs (-3.5)); Write (' <br>3.5 's rounding: ' +math.round (3.01)); Write (' <br>3.01: ' +math.ceil (3.01)); Write (' <br>3.99 's rounding: ' +math.floor (3.99)); Write (' <br> get maximum value: ' +math.max (10,20,45,12)); Write (' <br> get maximum value: ' +math.min (10,20,45,12)); Write (' <br> get pi ' +Math.PI); //math.random (): Gets the random number of the >=0 <1Write (' <br> get random number ' +math.random ()); /*//0-10 random number Math.Round (Math.random () *10); 0-0.5 0 0.5-1.5 1 1.5-2.5 2 9.5-10*/ //random number of 0-10Console.log (Math.ceil (Math.random () *100000)%11); //random number of 10-50 /*0-40 +10*/Console.log (Math.ceil (Math.random ()*100000)%41+10); //random number of m-n functionGetrandom (M, n) {returnMath.ceil (Math.random () *100000)% (n-m+1) +m; } console.log (Getrandom (2,3)); } </script>
JS Math [random number, absolute value, rounding, in-one rounding, rounding, maximum, minimum, pi]