There still seem to be some problems with the code though, such as the array needing to be of strings, and counting from 1 being inappropriate for arrays, it should count from 0 instead.
The timeout function cannot access the step/images/numOfImages variables either, so how do you want to deal with that?
Do you want them to be global variables, to be passed to the function, or to store them somewhere that the function can have access to?
I’ll pass them to the function in this case.
If we start the function with only the images, we can use a simple sanitization of the step variable to ensure that an undefined value for step becomes a number too.
And just to be picky, we’ll run that code through jslint.com (in “The Good Parts” mode) to easily pick up any remaining issues.
So, how’s this (it works now) as an improvement on the code?
That’s odd, I must have misunderstood another error in the previous code to be that issue.
Still, we now have viable working code for that tutorial from the year 2002.
if you’re interested, there’s a timeline from archive.org of changes to that tutorial page.