# How to calculate area of circle in JavaScript

In this example we will calculate area and circumference of the circle according to given radius. we use the following mathematical formula for calculating area and circumference of the circle In JavaScript:

circumference of the circle = 2 * radius * PI

Where radius is the radius of the circle and PI is the constant value of the pi.

```<html>
<title>Find the area and circumference of a circle</title>
<body>
<script language="JavaScript">
function CalculateArea(){
document.write("<P>The area of the circle is " + (radius * radius * Math.PI) + "</p>");
document.write("<P>The circumference of the circle is " + (2 * radius * Math.PI) + "</p>");
}
</script>
<form name=form1>
<br>
<input type="button" value="Calculate" onClick='CalculateArea();'>
</form>
</script>
</body>
</html>```

## 2 thoughts on “How to calculate area of circle in JavaScript”

1. Arjun says:

not working

1. Hirendra Sisodiya says:

hi Thanks

I have corrected the code..Actually i have just uncommented function ‘CalculateArea’…