I have a block of Javascript to pull a random gif that looks like this:
const gifs = ["1.gif", "2.gif", "3.gif"];
const random = Math.floor(Math.random() * gifs.length);
console.log(random, gifs[random]);
I want to place a gif inside an <img>
tag, like <img src="1.gif">
by using the random const to pull a random gif each time the page loads.
I added document.getElementById("giffetch").innerHTML = gifs;
and <img id="giffetch">
, but it didn’t work. I sense I’m close but missing a crucial element.