Math.cos() : cos : Math JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Math » cos »

 

Math.cos()








The cos() method calculates the cosine of a number.

It returns a numeric value between -1 and 1, representing the cosine of an angle.












<html>
    <body>
    <script language="JavaScript">
    <!--
    function doMath(){
        var inputNum=document.form1.input.value;
        var result = Math.cos(inputNum);
        document.form1.answer.value = result;
    }
    -->
    </script>
    <form name=form1>
    This exanple calculates the cosine of the entered number.
    <br><br>
    Enter First Number:
    <input type="text" name="input" size=10>
    <input type="button" value="Calculate" onClick='doMath()'>
    <br>
    The cosine is:
    <input type="text" name="answer" size=10>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Math
» cos