title: document.write will not show output
body: <p>When i write array element it will not show output when i click asending and desending no output will be printed....plese check my query if fault in it ...i think function is stop working when i click button it nothing show me </p>
  
  <pre><code>     &lt;html&gt;
     &lt;TITLE&gt;Javascript Arrays&lt;/TITLE&gt; 
     &lt;BODY bgcolor="#F0F0F0"&gt;
     &lt;h1&gt;Implementation of Sort and Reverse Functions &lt;/h&gt;     
       &lt;h2&gt;Enter number of Elements&lt;/h2&gt;
        &lt;form name="Anonymous Ghost"&gt;
       &lt;INPUT type="number" name="takeinput" id="valueField" size="30"&gt;
         &lt;Input type="button" name="name1" value="Take Input" onClick="a()"&gt; &lt;/form&gt;
       &lt;form name="Anonymous Ghost"&gt;
       &lt;Input type="button" name="name2" value="Ascending" onClick="b()"&gt;
       &lt;Input type="button" name="name3" value="Descending" onClick="c()"&gt;
        &lt;/form&gt;
  
            &lt;/BODY&gt;
          &lt;SCRIPT&gt;
       function a() {
           var val = parseInt(document.getElementById('valueField').value)
               var words = new Array(val);
            for (k = 0; k &lt; words.length; k = k + 1) {
      words[k] = window.prompt("Enter String # " + k, "");
             }
            }
  
          function b() {
         words.sort( ) ;
         document.write( "SORTED WORDS:" + "&lt;BR&gt;" ) ;
        for ( k = 0 ; k &lt; words.length ; k = k + 1 ) {
        document.write( words[ k ] + "&lt;BR&gt;" ) ;
         }
        }
  
           function c() {
         words.sort( ) ;
          words.reverse( ) ;
         document.write( "SORTED WORDS:" + "&lt;BR&gt;" ) ;
         for ( k = 0 ; k &lt; words.length ; k = k + 1 ) {
           document.write( words[ k ] + "&lt;BR&gt;" ) ;
           }
           }
           &lt;/SCRIPT&gt;
         &lt;/HEAD&gt;
          &lt;BODY&gt;
        &lt;/BODY&gt;
               &lt;/HTML&gt;
  </code></pre>