I'm new to javascript and webdev in general. Im also new here on stackoverflow. Its great!
I have found a snippet of javascript code that is working well for what I'm trying to achieve. The script shows random images from a folder but i need it to not repeat the images.
This is the script.
var random_images_array = ["smile.gif", "frown.gif", "grim.gif", "bomb.gif"];
function getRandomImage(imgAr, path) {
path = path || "images/";
// default path here
var num = Math.floor(Math.random() * imgAr.length);
var img = imgAr[num];
var imgStr = '<img src="' + path + img + '" alt = "">';
document.write(imgStr);
document.close();
}
I just can't figure out how to make it not repeat the images. I have read some solutions online but i guess im not there yet to fully grasp and recreate a working solution.