Deck Builder for PT JS course
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