title: use array to create dynamic image slider
body: <p>currently i am trying to create an image slider.a two element array is used to store the image sources.don't know whats wrong ,my slider is not working though everything looks fine .pls help me out .thanks</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
  #myimage {
      opacity=0;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script&gt;
  function lol(){
      var check=true;
      var i=0;
      var array=["car1.jpg","car2.jpg"];
      var imgs=doucment.getElementById("myimage");
      setInterval(function(){
          if(check){
              imgs.style.opacity=1;
              imgs.style.transition="opacity 2s ease-in-out";
              imgs.src=array[i];
              i++;
              if(i=2){i=0;}
              check=false;
          }else{
              imgs.style.opacity=0;
              imgs.style.transition="opacity 2s ease-in-out";
              check=true;
          }
      },2000);
  }    
  window.onload=lol;
  &lt;/script&gt;
  &lt;img src="" id="myimage"&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>