JavaScript Program Display Area of Circle Using Nested Function

Write a JavaScript program display area of circle using nested function.



Source Code
<html>
<head>
    <title> Nested function example </title>
</head>
<body>
<script language="javascript" type="text/javascript">  
    function Area(r)
    {
        function Square(x)
        {
            return x * x;
        }
        return 3.14 * Square(r);
    }
    document.write("Area : " + Area(12));
</script>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store