Giter VIP home page Giter VIP logo

war's Introduction

war

Start of the "war" project (algorithms)

##Step 1: Shuffle the deck Take a look at script.js. Examine what the two for loops do in conjunction with each other. What will the resulting array (deck) look like?

##Step 2: Deal the cards When the page loads the cards should be divided equally into each player's pile.

  • Write code that will automatically divide out the cards in deck between the two players
  • There are many ways to do this, try to come up with the easiest, simplest solution (remember, the deck is already shuffled at this point)

##Step 3: Create the 'war' algorithm Create an algorithm called war that determines the winner from a given pair of cards. It should be a function that accepts two cards as parameters, compares the value, and returns a winner. In the case that the cards are a tie, have the algorithm return false.

##Step 4: Create the 'play' function When the user clicks the 'Play!' button, your function should play the current pair of cards.

  • The two top cards on each deck should be sent to the war algorithm
  • The winner should receive both cards, which should be placed at the end of his/her deck
  • Call the "advance" function to continue play

##Step 5 (Black Diamond): Account for 'tied' cards If there is a tie, the play function should then check the 4th cards from each player's deck and determine the winner, who gets all of the previous cards.

war's People

Contributors

cahlan avatar tylermcginnis avatar eanplatter avatar chasesage22 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.