@codeca423 Also, I think it might make the code more clear if let picture = document... were changed to let pictures = document... so it’s clear that it’s an array of elements with the .picture class rather than one picture.
First of all, please don’t use images of code. Just cut and paste the text of the code.
As far as “What is the purpose of index inside if statement”, it’s hard to tell exactly what you mean so I’ll just pick one and go with that.
This function is to show slides. You are passing in a variable index to tell it which slide to show. Remember that if there are 10 slides, the indexes will be from 0-9. So, if the index is bigger or equal to 10 (index.length) then they’ve chosen an index past the end, so just go back to the beginning. The second line says that if they’ve been going backwards and try to chose one before the beginning (less than 0), then go to the last image.
These two lines handle if they are scrolling through the images. If they go past either end, it will just go to the other end so they can continuously loop through. This is how slide shows typically work.