cos()

The cos() method is used to calculate the cosine value of the given angle (number - see syntax), in the brackets. The returned value is a number between 1 and -1, which represents the cosine of the given angle. As with all mathematical methods, it is used with the Math object.

syntax:

Math.cos(number)

EXAMPLE

var cosNumber = 78 + 56;

document.write("The cosine of the addition of 78 and 56 is : " + Math.cos(cosNumber) )

The example first creates a new variable, called cosNumber, which holds the product of the division of 78 and 56, which represents the two angles being worked with. The document.write statement then writes some descriptive text, with the cos() method being invoked upon the contents of cosNumber. The output should look like the following:



The cosine of the addition of 78 and 56 is : -0.4638288688518717