I am currently working on implementing a deck object in JavaScript, with two separate files - one for the card constructor and the other for the deck logic. My goal is to create a load function within the deck object that will populate the deck with 52 unique card objects, but I'm struggling with how to properly loop through to achieve this.
Here is the code snippet for the card constructor (card.js):
function card(pRank, pSuit){
this.rank = pRank,
this.suit = pSuit,
this.used = false;
}
And here is the code snippet for the deck logic (deck.js):
deck = {
cardArray: [],
load: function(){
for(i=0; i<52; i++){
this.cardArray.push(card);
};
}
}