I want to create a website that will randomly download any photo from the catalog, except that the script has only the location of the folder from which the photos are to be displayed. Without file name. For example, I have the "images" directory and I want the script to display the image randomly (DO NOT ENTER THE FILE NAME).
This is my script:
const btnPhoto = document.createElement('button');
btnPhoto.innerText = 'change image';
const fieldPhoto = document.createElement('div');
document.body.appendChild(btnPhoto);
document.body.appendChild(fieldPhoto);
function getRandomArbitrary(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
btnPhoto.addEventListener('click', () => {
fieldPhoto.innerHTML = `<img src="${'*.jpg, *.png, *.bmp'[getRandomArbitrary(0, 1)]}">`;
});