Last active
April 20, 2024 18:31
-
-
Save leomastoras/9a0dc4d792dccf52297f101bac9b7999 to your computer and use it in GitHub Desktop.
Deck of cards
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
Array.prototype.hasOwnProperty('shuffle') || Object.defineProperty(Array.prototype, 'shuffle', { | |
value: function() { return this.sort(() => Math.random() - .5); } | |
}); | |
let deck = [...'♠♣♥♦'].flatMap(s => ('A,'+[...Array(11).keys()].slice(2)+',J,Q,K').split(/,/).map(c => c + s)); | |
console.log(deck); | |
console.log(deck.shuffle()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment