Here's an example of a slideshow. In the HEAD, load all the image data into an array. In the HEAD, define functions nextSlide and prevSlide . In the BODY, create a table with one row, two columns. Left column contains two buttons that invoke nextSlide and prevSlide.
Right column contains the named image tag.
We use square brackets to indicate the index. The elements of an array can be other kinds of objects, too, such as strings. Above, we put numbers in elements 0 and 1 of bob and a string in element number 2. We do that with a series of assignment statements. A variable declared outside a function can be used by any function, hence a global variable.