Help - simple slideshow

i hope it’s ok to ask about non FCC projects

i have an automatic slideshow that works fine, but the previous and next buttons are not working as expected

all help appreciated

Well, in your next and previous, you aren’t actually DOING anything except updating the counter value. What exactly are you expecting it to do?

showSlide() method has one parameter, in animate method i call showSlide with counter-1 as an argument, when clicking next counter should increse by one to display the next image
showSlide have an array stored in slides var, the passed argument will be used to display certain image as block instead of “none”

And that works fine, hence why the animation works. But your prevBtn and nextBtn handlers never actually call showSlide…

thanks alot i didn’t pay enough attention

It happens, no worries.

Now, I took your code, and tinkered a bit – I am a big fan of the new class syntax. So I created a Slideshow class, and simply created an instance of that. The advantage of this approach is, nothing is hard-coded into the class. It becomes much more flexible.

Not saying this is what you should do, it was more a thought experiment, but here’s a link to it in case you choose to see how it might work:

thank you that was helpful

Glad to help, please feel free to ask if any of it didn’t make sense.