I have this object:
var count = {
table: 15,
people: 34,
places_details: 85,
story_1: 21,
story_2: 6,
story_3: 11,
}
This array:
var categories = ['table', 'people', 'places_details', 'story_1', 'story_2', 'story_3']
And this function:
function preloadThumbs()
{
var j=0;
for (j=0; j<categories.length; j++)
{
var k=1;
for (k=1; k<=count[categories[j]]; k++)
{
$('#preload').append('<img src="graphics/thumbs/'+categories[j]+'/'+k+'.jpg" />');
}
}
}
...which goes through each folder by the name of categories[j]
and loads all the images into a hidden <div>
.
What's a way to write the data as a single object and change the corresponding function to interpret it correctly?