Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Math</h1>
<h2>The Math.cos() Method</h2>
<p>Math.cos() returns the cosine of an angel given in radians.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Cosine of 0 degrees is: " + Math.cos(0).toFixed(2) +
"<br>" +
"Cosine of 60 degrees is: " + Math.cos(Math.PI/3).toFixed(2) +
"<br>" +
"Cosine of 90 degrees is: " + Math.cos(Math.PI/2).toFixed(2) +
"<br>" +
"Cosine of 180 degrees is: " + Math.cos(Math.PI).toFixed(2) +
"<br>" +
"Cosine of 360 degrees is: " + Math.cos(Math.PI*2).toFixed(2);
</script>
</body>
</html>