Mega Code Archive

 
Categories / JavaScript Tutorial / Math
 

Use Math PI to do calculation

< html> <head> <title>Find the area and circumference of a circle</title> <script type="text/javascript" language="javascript"> <!-- // function FindArea(){     var number = new Number(123);     document.write("<P>You entered a radius of " + number + "</p>");     document.write("<P>The area of the circle is " + (number * number * Math.PI) + "</p>");     document.write("<P>The circumference of the circle is " + (2 * number * Math.PI) + "</p>"); } // --> </script> </head> <body onload="FindArea()"> </body> </html>