Practice Competency:

1.  What is the output for the following program:  Put a box around your answer:

<html>
   <head>
     <script type = “text/javascript”>
         <!–
         var a=1, b=7, c=9;

 while ( a < c )
  {
  document.writeln(“Junk” + a + “<br>”);
  if (a ==3)
         { 
           while ( b > 2)
   {
             document.writeln(“Loop” + b + “<br>”);
             if ( b == 3)
             {
             document.writeln(“go” + b + “<br>”);
             b=b-2;
             }
             b–;
           }
           }
           if (a == 5)
           document.writeln(“Skip” + a + “<br>”);
           if (a > 7)
           {
           b = b – 1;
           if ( a < 5)
           document.writeln(“Small” + b + “<br>”);
           }
           document.writeln(“Again” + a + “<br>”);
           a = a + 2
         }
     </script>
   </head>   
   </html>

2.  Write a JavaScript program to do the following:  You do not need HTML tags.

Enter test scores from the user until the user enters a number over 100 for the test score.  For each test, tell if it is an odd score between 70 and 90.   When you exit the loop, print the highest odd score in the 90s and the average of all even scores less than 80.

3.  Give the output for the following code.  Show the runtime stack.

<html>
<body>
  
   <script type=”text/javascript”>

       function junk(a,b)
       {
         
           var x=a+2;
           document.write(“begin” + a + b + c + “<br>”);
           a=b+1;
           document.write(x+”<br>”);
           c=c-1;
           document.write(“end” + a + b + c + “<br>”);
           return x;         
       }

       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=1;  b=5;  c=9;
       document.write(“init” + a + b + c + “<br>”);
       a = junk(b,a);
       document.write(“main” + a + b + c + “<br>”);
       stuff(a,b);
       document.write(“over” + a + b + c + “<br>”);

   
   </script>
  </body>