Code Monkey home page Code Monkey logo

deck-of-cards's Introduction

Deck of Cards

Used a javascript class to create a deck of cards.

Setup

$ git clone https://github.com/JoshuaBrigati/Deck-of-Cards.git  
$ cd Deck-of-Cards  
$ npm install  

If you do not have npm you can install it by installing NodeJS: https://nodejs.org/en/
Then run $ npm install again.

This uses NodeJS to run the file.
run $ which node to see if you have it installed.
If you do not have node installed, install it from https://nodejs.org/en/

If you do not install NodeJS the Run section will not work.

Run

After going through the Setup step,
run $ npm run givecard to receive a random card from a shuffled deck.

Functions

  • Shuffle: Shuffles the current deck of cards.
let myDeck = new Deck();
console.log("Original Deck: ", myDeck.deck); // Returns: Original Deck: ['Ace of Clubs', '2 of Clubs', '3 of Clubs', ...]
myDeck.Shuffle();
console.log("Deck after shuffled: ", myDeck.deck); // Returns: Deck after shuffled: ['5 of Diamonds', '2 of Clubs', 'Jack of Spades', ...] 
  • GiveOneCard: Gives back a single random card.
let myDeck = new Deck();
myDeck.Shuffle();
console.log("\nHere is your card: ", myDeck.GiveOneCard()); // Returns: Here is your card:  7 of Hearts

Test

To run tests:

$ npm test

deck-of-cards's People

Contributors

joshuabrigati avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.