title: need help Understanding javascript gallery code
body: <ol>
  <li>Hi I have created a slideshow for my html with the function to show a gallery of pictures one at a time with a function to showcase the next picture by clicking the arrow to move to the next picture, I am still unclear of this line of code and how it relates to the function of the slideshow. I referred to this website to complete the slide show : <a href="https://www.w3schools.com/howto/howto_js_slideshow.asp" rel="nofollow noreferrer">https://www.w3schools.com/howto/howto_js_slideshow.asp</a>
  May I ask if someone could explain what this line of code does ? Thanks a bunch !</li>
  </ol>
  <pre><code>var slideIndex = 1;
  showSlides(slideIndex);
  
  //calling of functions to let the slide move to the next picture
  function plusSlides(n) {
      showSlides(slideIndex += n);
  }
  
  function currentSlide(n) {
      showSlides(slideIndex = n);
  }
  
  function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName(&quot;mySlides&quot;);
      var dots = document.getElementsByClassName(&quot;dot&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;;
      }
      for (i = 0; i &lt; dots.length; i++) {
          dots[i].className = dots[i].className.replace(&quot; active&quot;, &quot;&quot;);
      }
      slides[slideIndex-1].style.display= &quot;block&quot;;
      dots[slideIndex-1].className += &quot; active&quot;;
  }
  </code></pre>