Languages

JavaScript - how to convert 45 degrees to radians?

6 points
Asked by:
Marcin
2453

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 answers
3 points
Answered by:
Marcin
2453

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
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,
    this community will help you.