Find out the circumference of a circle by entering its radius. Very simple!
<!– Paste this code into an external JavaScript file named: calc.js –>
/* This script and many more are available free online at
The JavaScript Source :: http://javascriptsource.com
Created by: Lee Underwood :: http://javascriptsource.com/ */
function circum() {
var radius = prompt(“Enter the radius of the circle”,””);
var circle = 2 * Math.PI * radius;
alert(“The circumference is “+circle+”.”)
}
<!– Paste this code into the HEAD section of your HTML document.
You may need to change the path of the file. –>
<script type=”text/javascript” src=”calc.js”></script>
<!– Paste this code into the BODY section of your HTML document –>
<form>
<input type=button value=”Calculate the circumference” onClick=”circum()”>
</form>
<p><div align=”center”>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”https://javascriptsource.com”>The JavaScript Source</a></font>
</div><p>