Page 255 - Web_Application_v2.0_C12_Fb
P. 255

Output:




















                 Example 58: To demonstrate the use of  random() method
                    <!DOCTYPE HTML>
                    <HTML>
                    <HEAD>
                    <TITLE>JavaScript Random</TITLE>
                    </HEAD>
                    <SCRIPT>
                    function display() {
                    var num = Math.random();
                    alert("Random number: " + num);
                    }
                    </SCRIPT>
                    </HEAD>
                    <BODY>
                    <INPUT type="button" onclick="display()" value="Generate Random Number">
                    </BODY>
                    </HTML>
                 Output:


















                 Example 59: To demonstrate the use of  max() method

                    <!DOCTYPE HTML>
                    <HTML>
                    <HEAD>

                    <TITLE>JavaScript Random</TITLE>

                                                                                                  JavaScript Part 2  253
   250   251   252   253   254   255   256   257   258   259   260