Created
September 16, 2014 03:51
-
-
Save PatrickLandin/da7629f2c0819037947c to your computer and use it in GitHub Desktop.
Class code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title> | |
Deck of Cards | |
</title> | |
</head> | |
<body> | |
<ul id="deck" class="collection"> | |
</ul> | |
<script> | |
function Deck() { | |
this.cards = ''; | |
for (var suit = 0; suit < 4; suit++) { | |
for (var rank =0; rank < 13; rank++) { | |
var card = new Card(suit, rank); | |
this.cards += card.show(); | |
}; | |
}; | |
var deck = document.getElementById('deck'); | |
deck.innerHTML = this.cards; | |
} | |
function Card(suit, rank) { | |
this.suit = suit; | |
this.rank = rank; | |
this.show = function() { | |
return '<li class="cards">' + this.suit + '-' + this.rank + '<li>'; | |
} | |
} | |
var deck = new Deck(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment