title: slide show used from w3 schools
body: <p>I have a question regarding a slide show I am building for an assignment. My debugging skills are not the best as I am new to HTML and JS. My problem comes from getting a typeError from a line in my slideshow JS. The problem is in this block here:</p>
  <pre><code> var slideIndex = 1;
   showSlides(slideIndex);
  
   function plusSlides(n) {
     showSlides(slideIndex += n);
   }
  
   function currentSlide(n) {
     showSlides(slideIndex = n);
   }
  
   function showSlides(n) {
    var i;
    var slides = document.getElementsByClassName(&quot;mySlides&quot;);
    if (n &gt; slides.length) {
      slideIndex = 1
    }
    if (n &lt; 1) {
      slideIndex = slides.length
    }
    for (i = 0; i &lt; slides.length; i++) {
      slides[i].style.display = &quot;none&quot;;
    }
    slides[slideIndex-1].style.display = &quot;block&quot;;
  }
  </code></pre>
  <p>The error is:</p>
  <pre>
  Uncaught TypeError: Cannot read property 'style' of 
  undefined at showSlides 
  </pre>
  <p>referring to this line:</p>
  <pre><code>slides[slideIndex-1].style.display = &quot;block&quot;;
  </code></pre>