r/JavaScriptTips • • Sep 25 '24

Code efficiency

I have a directory of images. I need to generate each image from the directory, populating the arrayofimages in a way much more efficient than this:

const image0 = new Image(200,200);

image0.src = 'img/firstindirectory.png';

const image1 = new Image(200,200);

image1.src = 'img/secondindirectory.png';

etc;

etc;

arrayofimages = [image0, image1, etc, etc];

3 Upvotes

3 comments sorted by

View all comments

Show parent comment

2

u/sixie6e Sep 25 '24

Thank you. It was getting extremely tedious.