Skip to content

Instantly share code, notes, and snippets.

@malchak
Created May 6, 2013 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save malchak/5523577 to your computer and use it in GitHub Desktop.
Save malchak/5523577 to your computer and use it in GitHub Desktop.
deckOfCards
var suits = ['Heart', 'Diamond', 'Club', 'Spade'];
var value = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'];
function Card(num, suit) {
this.num = num;
this.suit = suit;
}
function Deck() {
this.cards = [];
}
Deck.prototype = {
// shuffle: function() {
// this.cards.sort(){ return Math.floor(Math.random()*3-1)};
// },
// ***** CANNOT GET SAMPLE TO RETURN WITHOUT SYNTAX ERRORS *****
make: function() {
for(var i = 0; i < suit.length; i++) {
for(var j = 0; j < value.length; j++){
var card = new Card(value[j], suit[i]);
this.cards.push(card);
}
}
}
};
var deck1 = new Deck();
deck1.make();
console.log(deck1.cards);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment