Giter Site home page Giter Site logo

dice-game's Introduction

Dice Game

Setup

  • Fork this repository by clicking the "Fork" button (top-right corner of the remote repo)
  • Clone the new repository to your local machine
    • From the command line: git clone {the-forked-page-url}

Part 1: Variables, functions and elements

Steps

  1. Complete the steps in the HTML document to build a prototype interface for a dice game
    • See index.html for an example interface written within a comment block
  2. Call getRandomDiceRoll() and store the result as a variable named diceRoll
  3. Update user interface (document), showing the dice face (svg image) that matches the roll number
  4. Use diceRoll to update the label "You rolled: #" (replacing # with the roll)
  5. Wrap the dice roll procedure in a function named rollTheDice(), call it from the console to test
  6. Listen for a click to happen to the <button>, then callback to the function rollTheDice

Tips

  • Before starting, consider using the browser's developer tools to prototype a solution manually
    • Start by changing the document from the "Elements" tab to go from a roll 3 to roll 4
  • Next, consider prototyping within JS by assigning a number to diceRoll before getting a random
    • This will assist by creating a controlled case before assigning a random value
  • Use the console to test each line of code that affects the document, as you code
    • Mis-selecting elements will create errors that prevent the page from working as intended

Part 2: Control statements (conditions)

Complete these challenge exercises to enforce your understand of control statements:

  1. Develop the necessary condition statements to allow the roll number to be expressed as a word
    • For example, "You rolled: 3" should be "You rolled: three"
  2. Keep track of the previous roll value, such that if the same number is rolled twice consecutively, the output message will notify the user appropriately
    • For example, "You rolled another three"
  3. Add a second dice to the application interface to mimic the results of the popular casino game, "craps". Replace the result message ("Your rolled: ____") with the appropriate roll outcome based on the table below, reflecting the result of rolling both dice together Craps game results

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.