I have an array of images and would like to display them in a div tag using a loop, but none of the images are showing.
const images = ["images/image1", "images/image2", "images/image3"];
for (let x = 0; x < images.length; x++) {
const element = '<img src="' + images[0] + '">'
let pic = document.querySelector('.images').innerHTML += element;
pic;
}
picvariable.images[0]every time you read the first image. You should be usingxwhich is the index of the array.images[x]Now if the images do not show up, then you have an issue with the path to the image.