title: Whats wrong with my code?(changing pictures using javascript)
body: <p>I want the picture to change from bulb off to bulb on on the clicks of the two buttons.I have seen a similar example in W3schools, however, I can't see the difference between the codes. Please help.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;script&gt;
  function light(switch){
      var pi;
      if(switch == 0){
          pi = "pic_bulboff.gif"
      }
  &lt;!--this is if the switch value is zero--&gt;
      else{
          pi = "pic_bulbon.gif"
      }
  &lt;!--this is if switch value is anything else including 1--&gt;
      document.getElementById('sw').src = pi;
  }
  &lt;/script&gt;
  
  &lt;img id="sw" src="pic_bulboff.gif"&gt;
  
  &lt;button onclick="light(0)"&gt;Light off&lt;/button&gt;
  &lt;button onclick="light(1)"&gt;Light on&lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>