August 1999
Intermediate to advanced
1488 pages
72h 53m
English
math.cos(num)
The cos() method of the Math object is used to calculate the cosine of a number. It returns a numeric value between –1 and 1, representing the cosine of an angle.
Listing 6.157 shows how the cos() method is used to get the cosine of the number input by the user.
<html> <body> <script language="JavaScript"> <!–– Hide // function calculates the cosine of the input number // takes the input from the user and passes the value to // the cos() method which calculates the cosine value. function doMath(){ var inputNum=document.form1.input.value; var result = Math.cos(inputNum); ... |
Read now
Unlock full access