Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Javascript JavaScript method cos()

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript method cos()

Advertisement
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:

 

     

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 3, 2006

Related Tutorials

Discuss: JavaScript method cos()  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com