Increment number in array []!

Hey there,

I have a problem whit some code.
On every click on the “>” button i want to increment the number between the square brackets, so the image src to have another link.
All the links are inside an array.
Here is the link:


function renderBreedImages is the place you should look.

When you click a button, it always points to the same photo [0 + 1].
Those numbers should not be static.

Desired behavior is

if (not last image) show([current image + 1])

So you need to add that logic in the function.

My pseudocode:

   int current = breedImageArray.getCurrentImagePosition;
   int last = breedImageArray.length-1;
   if (current < last){
      int next = current + 1;
   } else {
   int next = 0;}
   breedImage.src =   breedImageArray[next];


1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.