Home
IT Knowledge
IT Career
Inspiration
Languages
EN

# JavaScript - calculate sin in degrees

7 points
Created by: Kate_C
2895

I prepared super simple example to calculate sin in degrees in JavaScript and decided to share with others. So in order to use this example we just need to change value of deg variable to some other value (in degrees).

``````// ONLINE-RUNNER:browser;

function calculateSin(deg) {
var radians = (Math.PI / 180) * deg;

}

var deg = 30;
var y = calculateSin(deg);

// sin(30 deg) = 0.49999999999999994
console.log('cos(' + deg + ' deg) = ' + y);``````

We can change deg to other valus. Examples of common calculations:

``````sin(0 deg) = 0
sin(15 deg) = 0.25881904510252074
sin(30 deg) = 0.49999999999999994
sin(45 deg) = 0.7071067811865475
sin(60 deg) = 0.8660254037844386
sin(90 deg) = 1``````

I prepated similar post but for calculation cos in degrees:

Hey 👋
Would you like to know what we do?
• Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
• We welcome everyone,
no matter what the experience,
no matter how basic the question is,