Function Read Practice

<script type=”text/javascript”>

function junk(a,b)
{

var c=a-1;
document.write(“begin” + a + b + c + “<br>”);
a=b+1;
c=c-1;
document.write(“end” + a + b + c + “<br>”);
return a;
}

function stuff(b,c)
{
b=b-1;
a=7;
document.write(“more” + a + b + c + “<br>”);
c=junk(b,a);
document.write(“start” + a + b + c + “<br>”);
}

a=3;  b=2;  c=9;
document.write(“init” + a + b + c + “<br>”);
b = junk(c,a);
document.write(“main” + a + b + c + “<br>”);
stuff(a,c);
document.write(“over” + a + b + c + “<br>”);

Solution

<html>
<body>

   <script type="text/javascript">

       function first(a,b) 
       {

           var c=8;
           document.write("start" + a + b + c + "<br>");
           a=a+2;
           c=c-1;
           document.write("end" + a + b + c + "<br>");
           return c-a;          
       }

       function second(b)
       {
            var a=4;
           document.write("begin sec" + a + b + c + "<br>");
           c=first(b,a);
           document.write("start" + a + b + c + "<br>");
       }

       a=1;  b=2;  c=9;
       document.write("init" + a + b + c + "<br>");
       a = first(b,a);
       document.write("main" + a + b + c + "<br>");
       second(a);
       document.write("over" + a + b + c + "<br>");

   </script> 
  </body>

</html>

Answer

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>