I want to display 4 random images but not have duplicates. So if image one is "aceclubs.p ng" I don't want image two to be the same thing.
I've been duplicating this script with different function names for all four images, but sometimes they return the same image and I don't want that. Is there a way to put it all in one function?
(sorry for the newbiness of this question and/or bad formatting of the code. I'm new to this)
Any help greatly appreciated.
I've been duplicating this script with different function names for all four images, but sometimes they return the same image and I don't want that. Is there a way to put it all in one function?
(sorry for the newbiness of this question and/or bad formatting of the code. I'm new to this)
Any help greatly appreciated.
Code:
function random_cards(){
var cardace = new Array(4)
cardace[0] = "aceclubs.png";
cardace[1] = "acediamonds.png";
cardace[2] = "acehearts.png";
cardace[3] = "acespades.png";
var randomace = Math.floor(Math.random()*cardace.length);
var ace = cardace[randomace];
card1.src=ace
Comment