Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem 7. Print a Deck of 52 Cards
- //
- // Write a program that generates and prints all possible cards from a standard deck of 52 cards (without the jokers).
- //
- // The cards should be printed using the classical notation (like 5 of spades, A of hearts, 9 of clubs; and K of diamonds).
- // The card faces should start from 2 to A.
- // Print each card face in its four possible suits: clubs, diamonds, hearts and spades.
- // Use 2 nested for-loops and a switch-case statement.
- // Note: You may use the suit symbols instead of text.
- //
- // Examples:
- //
- // 2 of spades, 2 of clubs, 2 of hearts, 2 of diamonds
- //
- // 3 of spades, 3 of clubs, 3 of hearts, 3 of diamonds
- //
- // K of spades, K of clubs, K of hearts, K of diamonds
- //
- // A of spades, A of clubs, A of hearts, A of diamonds
- for (let i = 2; i <= 52; i++) {
- if (i <= 10) {
- console.log(i + ' of \u2660, ' + i + ' of \u2663, ' + i + ' of \u2665, ' + i + ' of \u2666');
- } else if (i === 11) {
- console.log('J of \u2660, ' + 'J of \u2663, ' + 'J of \u2665, ' + 'J of \u2666');
- } else if (i === 12) {
- console.log('Q of \u2660, ' + 'Q of \u2663, ' + 'Q of \u2665, ' + 'Q of \u2666');
- } else if (i === 13) {
- console.log('K of \u2660, ' + 'K of \u2663, ' + 'K of \u2665, ' + 'K of \u2666');
- } else if (i === 14) {
- console.log('A of \u2660, ' + 'A of \u2663, ' + 'A of \u2665, ' + 'A of \u2666');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement