Giter Site home page Giter Site logo

hangman-game's Introduction

Hangman Game

Setup

  • Clone the repo to your local system
git clone <repo url> 
cd repo_name
  • Initialize npm project
npm init

Note: Make sure you have index.js or main.js file, if not then just create it manually

  • Install [ReadlineSync] package from npm and test it.

✨Start coding the game✨

Hangman Gameplay

Here is an example of gameplay:

Guess the word:
_ _ _ _ _
You can make 3 incorrect guesses before losing
 
> input: a

Correct guess:
_ a _ _ _

> prompt: e

Incorrect guess, you have 2 more incorrect guesses left:
_ a _ _ _

> prompt: h

Correct guess:
h a _ _ _

> prompt: s

Incorrect guess, you have 1 more incorrect guesses left:
h a _ _ _

> prompt: p

Correct guess:
h a p p _

> prompt: y

Correct guess:
h a p p y

You have won the game!

In case the user runs out of the incorrect guesses then you should show this message

You have run out of guesses, the correct word was:
h a p p y

Requirements

  • Wrap everything in a single main function.
    • You should write helper functions which will be called from the main function you wrote
  • We should be able to play the game by running node index.js
  • The random word should be chosen from an array of words as given in the file words.js

Part 1

Break down the problem into at least 3 sub-parts

Part 2

Write the hangman game.

Stretch

Draw the ASCII art of hangman with every step, like this

      ╔═══╗
      |   ║
      O   ║
     /|\  ║
       \  ║
     ███  ║
    ══════╩═══

hangman-game's People

Contributors

archisvaze avatar

Watchers

 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.