constructor-word-guess

Word Guess Game via Node.js and Constructors

Overview

Command-line Word Guess game using constructor functions.

Constructor Word Guess

Playing the Constructor Word Guess

Technologies

Features

The Word Guess game contains the following files and features:

  1. letter.js
    • Contains a constructor, Letter, with a string (letter) and a boolean (guessed) value.
    • Letter contains a function that returns either an underlying letter or an underscore, based on whether the game letter has been guessed.
    • Letter contains a function that takes the user’s guess as an argument and checks it against the underlying letter, setting the letter’s guessed value to true if the letter was guessed correctly.
  2. word.js
    • Contains a constructor, Word that depends on the Letter constructor, that creates an array containing each letter of the game word the user is attempting to guess.
    • Word contains a function that calls displayWord() function, which concatenates a string representing the game word, calling the display() function defined in letter.js on each letter object and displaying guessed letters or an underscore for unguessed letters.
    • Word contains a function that takes a user guess as an argument and calls the guessWord function on each letter object, calling the check() function defined in letter.js and setting the letter’s guessed value to true when the letter is guessed correctly.
  3. index.js
    • Containing the logic for the game and depends on word.js.
    • Randomly selects a game word from an array of words.
    • Uses the Word constructor to store the game word.
    • Prompts the user their guess on the game word letters.
    • Tracks the user’s remaining guesses, subtracting a guess each time the user guesses incorrectly.
    • The game ends if the user runs out of guesses (10) or the user guesses all of the game letters before they run out of guesses.
    • A new game starts automatically after a win or loss.

Development Details

Developer

Pam Kelly at esq.kelly@gmail.com

GitHub

Github at https://github.com/PLKGIT/constructor-word-guess

Deployed Application (Example)

README Link at https://plkgit.github.io/constructor-word-guess/

Portfolio

Professional Porfolio at https://www.pamkelly.com/portdev.html

Copyright © 2019-2020 Pamela L. Kelly