The plusSlides function is called on the arrows to the left and right of the picture. When clicking on these arrows, it moves the picture one to the left or one to the right.
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
The currentSlide function is called on the dots beneath the picture. Clicking on the dots moves to a specific slide.
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
With both functions above, the n is passed into those functions through the inline javascript in the html (the onclick attributes). The slideIndex variable is a marker for which picture is currently being shown (when slideIndex is one, show the first picture. When slideIndex is two, show the second, etc.).
Also, here’s those functions rewritten below to be more clear, they do the exact same thing.
// function triggered by arrows on left and right of picture
function plusSlides(n) {
slideIndex = slideIndex + n;
showSlides(slideIndex);
}
// function triggered by dots beneath picture
function currentSlide(n) {
slideIndex = n;
showSlides(slideIndex);
}
The final showSlides function is what actually changes the css to show/hide picture slides. It finds all the slide divs and puts it into an array with this line:
var slides = document.getElementsByClassName("mySlides");
It hides them all with the first for loop by setting their css display property to none.
Then, it takes the slideIndex, uses that index to find the correct slide in the slides array, and sets its css display property to block (which makes the image appear):
slides[slideIndex-1].style.display = "block";
There’s also some other things this function does, like making sure slideIndex is between 1 and 3, changing the dot css and so on.
To be fair, this isn’t the best code, and the way they use n and slideIndex in the showSlides function is kinda confusing. I hope this helps somewhat though.