I like a more general functional approach:
/**
* converts a trig function taking radians to degrees
* @param {function} trigFunc - eg. Math.cos, Math.sin, etc.
* @param {number} angle - in degrees
* @returns {number}
*/
const dTrig = (trigFunc, angle) => trigFunc(angle * Math.PI / 180);
or,
function dTrig(trigFunc, angle) {
return trigFunc(angle * Math.PI / 180);
}
which can be used with any radian-taking function:
dTrig(Math.sin, 90);
// -> 1
dTrig(Math.tan, 180);
// -> 0
Hope this helps!