title: Returns [object HTMLSpanElement]
body: <pre><code>&lt;form&gt;
     &lt;table&gt;
       &lt;tr&gt;
          &lt;td&gt;Distance:&lt;/td&gt;
          &lt;td&gt;&lt;input type="number" id="distance" onKeyUp="calculate();"&gt;m&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
          &lt;td&gt;Time:&lt;/td&gt;
          &lt;td&gt;&lt;input type="number" id="time" onKeyUp="calculate();"&gt;s&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
          &lt;td&gt;Speed:&lt;/td&gt;
          &lt;td&gt;&lt;span id="speed"&gt;21&lt;/span&gt;&lt;span id="unit"&gt;&amp;nbsp;m/s&lt;/span&gt;&lt;/td&gt;
       &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
  
     var calculate = function() {
        var distance = document.getElementById("distance").value;
        var time = document.getElementById("time").value;
        var speed = distance/time;}
        if (speed=="Infinity" || speed=="NaN") {
           document.getElementById("speed").innerHTML="Invalid Input";
           document.getElementById("unit").innerHTML="";
        } else {
           document.getElementById("speed").innerHTML=speed;
        }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I am making a simple speed calculator but it isn't working. The output comes <strong>[object HTMLSpanElement]</strong>
  Any help will be appreciated for I am new to javascript.</p>