card-draw
v1.0.3
Published
NPM Package to randomly draw a card from a full deck.
Downloads
17
Maintainers
Readme
cardDraw
NPM Package to randomly draw a card from a full deck.
Installation
npm install card-draw
Usage
import cardDraw from 'card-draw'; // if you don't want the drawn card to be replaced in the deck
import cardDrawReplacement from 'card-draw' // if you want the card to be replaced in the deck
console.log(cardDraw()) // returns a randomly selected card as an object and removes it from the deck
console.log(cardDraw().suit) //returns the suit of the randomly drawn card and removes it from the deck
console.log(cardDrawReplacement()) // returns a randomly selected card as an object and keeps it back in the deck
console.log(cardDraw().suit) //returns the suit of the randomly drawn card and keeps it back in the deck
Notes
Adjust the 'value' property of the cards in accordance with the relevant game rules.