Created
August 30, 2017 01:37
-
-
Save craigquincy/4f533a62b6d43b6efa76b6479ac29685 to your computer and use it in GitHub Desktop.
Deck Builder for PT JS course
This file contains hidden or 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
let faceCards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | |
let faceNames = [undefined, "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"] | |
let cards = [ | |
["Spades", faceCards], | |
["Clubs", faceCards], | |
["Hearts", faceCards], | |
["Diamonds", faceCards] | |
] | |
// go over each suit array | |
for (let suitIndex = 0; suitIndex < cards.length; suitIndex++) { | |
// need javascript to help me | |
let suit = cards[suitIndex][0] | |
let faces = cards[suitIndex][1] | |
// go over every face card in the other array | |
for (let faceIndex = 0; faceIndex < faces.length; faceIndex++) | |
{ | |
let cardFaceName = faceNames[faces[faceIndex]] | |
let card = cardFaceName + ' of ' + suit | |
console.log(card) | |
} | |
} | |
// console.log(cards) | |
// make an array to hold cards | |
// randomly pick a card | |
// while loop to fill up your array until you have seven cards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment