Struggling With Mystery Word Game

The instructors weren’t kidding when they said that this is a big weekly project (The Mystery Word Game) that we have to be very careful with our programming. The purpose this weekly project was to implement the game Mystery Word as a web application where the user will be playing against the computer. For this project, I have already NPM install express, mustache-express, express-session, and body-parser to be used throughout the programming.

The idea of the Mystery Word Game:

  • A new user arrives (who hasn’t signed up) arrives at the root page, the app will select a random word from the list of words that YOUR computer has in store.
    • How are we supposed to access this list of words? We must be able to receive it with Node.
  • Store the chosen word during a session
    • We must use express-session
  • Note that the word chosen will not be shown. The user must guess a letter for that word. Basically, it is like a hangman game (which it really is anyway).
    • A form must be used where it can validate only one letter is being sent.
    • If more than one letter is entered–it must show that the input is invalid and tell the user to try again
  • Whatever letter is guessed that is not the correct letter for a chosen word–it must be shown somewhere on the page so that the user knows what letter they already used.
    • This is where express-session come in play
  • Whatever letter that is guessed and is correct will be shown on the display of a chosen word–but it will be partially shown until all the necessary words are added
    • Will need to somehow show those “underscores” where the missing letters are shown.
  • A user is allowed eight guesses where they will be reminded how many guesses they have left after each round of letter guessing.
    • Again, express-session plays a role here

This may sound easy to do–but I don’t think so, especially if this is not planned out accordingly before actually program the steps. Already, I find myself having issues with using the for loop inside the web app that is not displaying the words that I needed. I have already done the simple for loop outside of the web app to ensure that I am programming it correctly…and still, it is not working. Perhaps my brain is a bit tired that I am overlooking a very simple solution to this.

I am currently hard coding the first steps which are to use the for loop to go through an array and for some reason, it is not working when I am asking for the correct element and push it to a new array to single out the word.

Below is the code I’ve been working on and it is the first step to programming the game which for some reason is not displaying the word on the root page. Before I did the for loop, it does display the example words when I used the mustache tag (used the node library called express-mustache). Now, I brought in the for loop to get it to show up only one word instead of the whole array…it decides to not display any of the words. So, it is a struggle for me but I know it has to be a simple solution and/or I am practically overlooking something.

const example = ['cat', 'dog', 'horse', 'flea', 'mite', 'shark', 'fish', 'seahorse', 'graywolf'];

const game = [ ];

app.get('/', function(request, respond){

for (let i = 0; i > example.length; i++){
if (example[i] === "flea"){

respond.render('index', {
DropWord: game,}

Note: This is only partial programming I am showing as I have a lot more codes in the app.js file currently. I am doing the programming in baby steps to ensure that one block of code works before working on the next block of code.

Coding Terminology

I am still doing some pre-work assignments provided by the Iron Yard. So far, it had been an easy ride until I hit some bumps. I’m noticing some various terms being used in the coding world that I’ve heard of but never really knew the meaning behind it.

  • What is API?
  • What is node.js?
  • What is the difference between Java and Javascript?

Knowing how I am, I knew I would go crazy with the research on the three questions I had so far–but I will take it all in a stride. I eventually will understand what they are. After all, I studied and practiced how to do SQL–so, I knew I can figure this out.

Right now, I’m reading up on Atom, a text editor, recommended by Iron Yard. From what I’ve read–it seems like it would create a smooth ride for me to learn how to code using Atom while avoiding issues I could have had with other text editors like browser compatibility. On the plus side, it is open source!

Now…I’m going to learn how to install the Atom text editor and see where that gets me.