Home Javascript JavaScript method cos()



JavaScript method cos()
Posted on: April 3, 2006 at 12:00 AM
This section illustrates you the use of JavaScript method cos(). The method cos() returns the cosine of the specified number. It returns the numeric value between -1 and 1.

JavaScript method cos()

     

This section illustrates you the use of JavaScript method cos(). The method cos() returns the cosine of the specified number. It returns the numeric value between -1 and 1.

Its syntax is:

Math.cos( x )

where x is any number.

 

Here is the code:

<html>
<script>
function calculate(){
var i = Math.cos(30);
document.write("The cos value of 30: " + i); 
document.write("<br>");
var j= Math.cos(90);
document.write("The cos value of 90: " + j); 
}
</script>
<body>
<h2>Use of method cos()</h2>
<button onclick="calculate()">Show Cos value</button>
</body>
</html>

Output will be displayed as:

On clicking the button, the cosine values of the specified numbers will be displayed:

Download Source Code:

 

     

Related Tags for JavaScript method cos():


More Tutorials from this section

Ask Questions?    Discuss: JavaScript method cos()  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.