Circle Radius Calculation | Web Scripts | Crax

Welcome To Crax.Pro Forum!

Check our new Marketplace at Crax.Shop

   Login! SignUp Now!
  • We are in solidarity with our brothers and sisters in Palestine. Free Palestine. To learn more visit this Page

  • Crax.Pro domain has been taken down!

    Alternatives: Craxpro.io | Craxpro.com

Circle Radius Calculation

Circle Radius Calculation

LV
0
 

arobnu62

Member
Joined
Jul 19, 2023
Threads
2
Likes
0
Credits
190©
Cash
0$
Here's a basic JavaScript script that demonstrates a simple function to calculate the area of a circle given a radius.

function calculateCircleArea(radius) {
if (radius < 0) {
return "Radius cannot be negative";
}
var area = Math.PI * Math.pow(radius, 2);
return "The area of the circle is: " + area.toFixed(2);
}

Users can call this function with a radius value, and it will return the area of the circle with that radius. For example:

javascript

console.log(calculateCircleArea(5));
This code will output: "The area of the circle is: 78.54" (rounded to 2 decimal places). If the input is a negative number, it will return "Radius cannot be negative".
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Top Bottom