This is because the input / parameter of the function cosmust not be in degrees in radians .
From MDN docs :
Parameters
x: number indicated in units of radians .
So, before calling the function, convert the input to radians.
Use formula Radians = Degrees * ( Pi / 180)
source
share