Random Image
by Ketan Patel
HTML
<img src="" id="dynamicImage" />
JavaScript
// create array of image URLs
var cards = ['https://upload.wikimedia.org/wikipedia/commons/d/d2/A_party_tray_of_sliders_at_a_restaurant.jpg','https://www.thedailymeal.com/sites/default/files/story/sliders15promo.jpg', 'https://assets.justinmind.com/wp-content/uploads/2020/11/slider-design.png'];
// get the image element
var image = document.getElementById("dynamicImage");
// set the image src to a random image URL
image.src = cards[Math.floor(Math.random() * cards.length)];