Basically, what happens is every time I refresh my page, there's a slight chance that my for loop goes from 1 to 0. I don't know why this happens, but it's affecting the way my images layer over each other.
I tried to use a foreach loop, but it still gave me the same results.
Here's the code to the for loop:
for (let index = 0; index < Img.length; index++) {
const element = Img[index];
fs.readFile(__dirname + '/assets/textures' + element, function(err, data) {
console.log("Index: " + index);
});
};
And the array is pretty straight forward.
let Img = ["/red.png", "/face.png"];
I'm doing this all on server. NodeJS