Gallery Help

I’m using the Kirupa tutorial by superbeener

I’ve got a problem where my output show NaN. I’m getting that displayed when I press my buttons to go forward or back.

Please help.