I am relatively new to JavaScript and I am build a little app which randomly generates a card from a set of 52 cards (I stored all possibilities in an array). But I want to make sure that the same card can not be generated twice. I was not able to find a way to do so.
var cardType = ["A♠","2♠","3♠","4♠","5♠","6♠","7♠","8♠","9♠","10♠","J♠","Q♠","K♠"];
function generateCard()
{
var card = cardType[Math.round(Math.random() * (cardType.length - 1))];
}
The spade symbols are not actually in my array I just put it in for visibility.