Question

Create a script that presents a word-guessing game. Allow users to guess the word one letter at a...

  • Create a script that presents a word-guessing game.
  • Allow users to guess the word one letter at a time by entering a character in a form.
  • Start by assigning a secret word to a variable.
  • After each guess, print the word using asterisks for each remaining letter, but fill in the letters that the user guessed correctly.
  • Store the user’s guess in a form field.
  • For example, if the word you want users to guess is “suspicious” and the user has successfully the letters “s” and “I”, the store s*s*i*i**s in the form field.
  • You need to use the multiple arrays along with the split and join methods to create the game’s functionality.
  • Clear the guessed character from the form each time it is submitted, and add functionality that displays an alert dialog box if the user fails to enter a character.
  • Save the document as GuessingGame.htm.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

<!DOCTYPE html PUBLIC '-//W#C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1"/>
<title>Guessing Game</title>
<script type="text/javascript">
/*<![CDATA[*/
var mysteryWord="expertsolutions";
var displayWord="";
var passwordArray=new Array()
var mysteryWordArray = new Array();

function FillIn()
{
for(var i=0;i<mysteryWord.length;i++)
   {
   passwordArray[i] ="*";
   }
   document.forms[0].secretWord.value=passwordArray.join("");
}

function guessWord(character)
{
mysteryWordArray=mysteryWord.split("");
   var isCorect = false;
   for(var j=0;j<mysteryWordArray.length;j++)
   {
   if(mysteryWordArray[j]==character)
   {
   passwordArray[j]=character;
       isCorect=true;
   }
   }
   if(isCorect==false)
   window.aler("Your Guess is not Coreect. Please Try Again!...");
   document.forms[0].secretWord.value=passwordArray.join("");
}
   /*]]>*/
   </script>
   </head>
   <body onload="FillIn();">
   <h2> An interesting Guessing Game</h2>
   <form action="">
   <p>Secret Word: <input type="text" name="secretWord" readonly="readonly"/></p>
   <p>Guess Character: <input type="text" name="guessCharacter"/></p>
   <p><input type="button" value="Guess" onclick="guessWord(document.forms[0].guessCharacter.value);"/></p>
   </form>
   </body>
   </html>

Add a comment
Know the answer?
Add Answer to:
Create a script that presents a word-guessing game. Allow users to guess the word one letter at a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a script that presents a word guessing game. Allow users to guess the word letter-by-letter by entering a character in a form. Start by assigning a secret word to a variable named $secret. Afte...

    Create a script that presents a word guessing game. Allow users to guess the word letter-by-letter by entering a character in a form. Start by assigning a secret word to a variable named $secret. After each guess, print the word using asterisks for each remaining letter but fill in the letters that the user guessed correctly. You need to store the user’s guess in a hidden text field name $hidden_guess. For example, if the word you want users to guess...

  • Simple JavaScript and HTML: You'll create a simple word guessing game where the user gets infinite...

    Simple JavaScript and HTML: You'll create a simple word guessing game where the user gets infinite tries to guess the word (like Hangman without the hangman, or like Wheel of Fortune without the wheel and fortune). Create two global arrays: one to hold the letters of the word (e.g. 'F', 'O', 'X'), and one to hold the current guessed letters (e.g. it would start with '_', '_', '_' and end with 'F', 'O', 'X'). Write a function called guessLetter that...

  • Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The...

    Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The game requires the user to guess a secret word. The game does not end until the user guesses the word. After they win the game, they are prompted to choose to play again. The secret word that user must guess is "valentine". It is a case-sensitive analysis With each guess... If the guess does not have an equal number of characters, tell the user...

  • Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The...

    Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The computer must select a word at random from the list of avail- able words that was provided in words.txt. The functions for loading the word list and selecting a random word have already been provided for you in ps3 hangman.py. 2. The game must be interactive; the flow of the game should go as follows: • At the start of the game, let the...

  • Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually...

    Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually kind of confusing to me. I keep getting lost in all of the words even though these are supposed to instruct me as to how to do this. Can I please get some help as to where to start? Word guessing game: Overview: Create a game in which the user has a set number of tries to correctly guess a word. I highly recommend...

  • Please create a Hangman game in Java language. For this game a random word will be...

    Please create a Hangman game in Java language. For this game a random word will be selected from the following list (abstract, cemetery, nurse, pharmacy, climbing). You should keep a running tab of the user’s score and display it on screen; the user begins with 100 pts possible if they correctly guess the word without any mistakes. For every incorrect letter which is guessed, 10 pts should be taken away from what is left of their total possible points. For...

  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • Using C programming REQUIREMENTS: This program is a letter guessing game where a simple Al opponent...

    Using C programming REQUIREMENTS: This program is a letter guessing game where a simple Al opponent generates a secret letter for the user to guess. The user must be able to take turns guessing the secret letter, with the Al responding to the user's guesses. After successfully guessing, the user must be allowed to play again. The Al must count how many turns the user has taken. Here is an example of a game in progress where the human user...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • Overview In this exercise you are going to recreate the classic game of hangman. Your program...

    Overview In this exercise you are going to recreate the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. Requirements Rules The program will use 10 to 15 words as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT