node js how to pull random img in html code example
Example 1: random image and link js
<script type="text/javascript">
var images = [],
index = 0;
images[0] = "<a href = 'https://www.computerhope.com/'><img src='https://www.computerhope.com/banners/banner.gif' alt='Visit Computer Hope'></a>";
images[1] = "<a href = 'https://www.computerhope.com/history'><img src='https://www.computerhope.com/banners/banner2.gif' alt='Computer History'></a>";
images[2] = "<a href = 'https://www.computerhope.com/'><img src='https://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>
Example 2: how to set random dice image with js
function mathRandomDice() {
document.getElementById("dice").innerHTML = Math.floor(Math.random() * 6) + 1;
}
var x = mathRandomDice;
if (x = 1) {
d.innerHTML = '<img src=https://image.ibb.co/cQKOhc/dice1.png>';
}