Languages

JavaScript - how to convert 45 degrees to radians?

6 points
Asked by:
Marcin
15680

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
15680

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
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join