title: Calc Median JavaScript
body: <p>I need a "median" button that will calculate the median of the drawn numbers from the table.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; Numery losowania &lt;/title&gt;
  &lt;script&gt;
      var n1= Array.from({length: 9}, () =&gt; Math.floor(Math.random() * 70));
   
      document.writeln("&lt;table border = \"1\"");
  
      n1.sort((a,b) =&gt; a-b); // sort the array
     
      for(var i=0; i &lt; n1.length;i++)
      {
          document.writeln("&lt;tr&gt;&lt;td&gt;" + n1[i] + "&lt;/td&gt;&lt;/tr&gt;");
      }
      document.writeln("&lt;/table&gt;");
  &lt;/script&gt;
  &lt;form&gt;
  &lt;input type="button" value="Odśwież" onclick="location.reload()"&gt;
  &lt;/form&gt;
  &lt;/head&gt;</code></pre>
  </div>
  </div>
  </p>