Javascript- lorem image? array

I am new at JS and am trying to create a random picture each time the function occurs. Right now if I use a lorem pixel my functions all have same picture. Here is my JS div code:

var div3 = document.createElement('div3');
div3.textContent = "";	
div3.setAttribute('class', 'ev-image');

I believe I have to create an array, but I am not exactly sure how to add it within this code. Any help is appreciated. Thank you!

If you’re wanting to use an array, I’d recommend setting up an array of picture URLs like this

const imageURLs = 

and then when you’re setting the background-image property, you should be able to do something like

"background-image:url(" + imageURLs[<random index>] + ")"

For generating a randomIndex, Math.floor() and Math.random() are your friends.
(Info on generating random numbers in Javascript:

Hope it helps!

You can use the random endpoint, look at the docs for “Multiple images on the same page”.

This worked but still has the possibility of generating two of the same image…

If you want to do the array method instead of using the endpoint, you can check the current random index against the last random index and run the get random index code again if they are the same.