Languages

JavaScript - how to convert 45 degrees to radians?

6 points
Asked by:
Marcin
18610

I have 45 degrees and I want to convert it to radians.
Expected result is 0.785398.

var degrees = 45;
var radians = ?

How can I do it with JavaScript?

1 answer
3 points
Answered by:
Marcin
18610

Try to use the code:

// ONLINE-RUNNER:browser;

var degrees = 45;
var radians = (Math.PI / 180) * degrees;

console.log(radians);

Read more about conversion here:

https://dirask.com/posts/JavaScript-convert-degrees-to-radians-deg-to-rad-k1w2lj

0 comments Add comment
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join