I have a few (hundred) variables:
var image1 = 'xxxx';
var image2 = 'yyyy';
var image3 = 'zzzz';
etc…
I’m trying to use a while loop to incorporate these images in a function like so:
i = 0;
while (i<100) {
$("#somediv").append(image + i);
}
I understand why this would not work, since first it will look for a variable image, then append variable i to that.
How can I accomplish this? Naming the variables as an array at first? I’m not too familiar with javascript, and understand PHP moreso. In PHP I could do function $var($i) and increment $i++.
Thanks for your help!
Instead of having individual variables for each image, consider using one array, and iterating that.