CancelImage Upload

How to load and return PI in JavaScript

If you are in need of PI within your JavaScript code, and do not feel like having to enter the exact number every time you require it's services, you need not worry. Here's is an easy way of accessing it:

var pi = Math.PI;

Here a more extended HTML example which Prints Pi to a HTML document:

<html>
<head>
<title>How to return PI in JavaScript</title>
<script language="JavaScript">

function printPi()
{

       var pi = Math.PI;

       document.write("PI = " + pi);

}

</script>
</head>
<body onload="javascript:printPi();">

</body>
</html>

Piece of cake!

Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com