Page 211 - Web_Application_v2.0_C12_Fb
P. 211

Output:














                 Some examples of JavaScript Function are provided here.
                 Example 21: To find the greatest of three numbers

                    <!DOCTYPE HTML>

                    <HTML>
                    <HEAD>
                    <TITLE>To display the greatest of three numbers</TITLE>
                    </HEAD>
                    <BODY>

                    <H2>JavaScript Functions</H2>
                    <P>Function to display the greatest of three numbers</P>
                    <SCRIPT>
                    function gr_num(p,q,r) {

                    if (p>q && p>r)
                    return p;
                    else if (q>p && q>r)
                    return q;

                    else
                    return r;
                    }
                    result=gr_num(56,78,23); //Assuming all 3 numbers are different

                    document.write("The greatest number is "+result);
                    </SCRIPT>
                    </BODY>
                    </HTML>
                 Output:

















                                                                                                  JavaScript Part 2  209
   206   207   208   209   210   211   212   213   214   215   216