Skip to content

memoev/guess-constructor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

guess-constructor

Word Guess command-line game using constructor functions, Node and the inquire package.

Value Proposition 🎯

A little fun with this guessing words game running on node.js! To start playing you type in letters either on upper or lower case.

Instructions 📝

  • Start by running node index.
  • Input letters to try to find out which letters hide behind the underscore.
  • Whenever you get the word right, it will prompt and ask if you want to keep on playing.
  • Words might repeat.
  • Lastly, you only get 10 attempts per word.

Code Overview 🌳

The most import piece of code on this repository is the use of object constructors and the npm package inquirer. The main constructor running the checks is the Letter constructor inside letter.js:

function Letter(char) {
    this.wordPlaceholder = [char];
    this.guessed = false;
    this.guessedLetter = function () {
        if (char === ' ') {
            this.guessed = true;
            return ' ';
        } else if (this.guessed === false) {
            return '_';
        } else {
            return char;
        };
    };
    this.letterChecker =  function (guessChar) { 
        if (guessChar === this.wordPlaceholder[0].toUpperCase() || guessChar === this.wordPlaceholder[0].toLowerCase()) {
            this.guessed = true;
        };    
    }
}

module.exports = Letter;
}

Prerequisites 💻

Working web browser (e.g Chrome, Firefox, Safari, Opera, etc.) from the list of browser that support jQuery (https://jquery.com/browser-support/):

  • Desktop:

    • Chrome: (Current - 1) and Current
    • Edge: (Current - 1) and Current
    • Firefox: (Current - 1) and Current, ESR
    • Internet Explorer: 9+
    • Safari: (Current - 1) and Current
    • Opera: Current
  • Mobile

    • Stock browser on Android 4.0+
    • Safari on iOS 7+

    You'll also need to install inquirer and node on your client by running the following on your terminal:

    npm i inquirer
    brew install node

Example Images

Images showing results can be found inside the example-images folder in the root of this repository.

About

Word Guess command-line game using constructor functions, Node and the inquire package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published