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...

  • In PYTHON 3- Implement a subclass (described below) of "Word Guess", a variant of the game...

    In PYTHON 3- Implement a subclass (described below) of "Word Guess", a variant of the game Hangman. In this game, a word is first randomly chosen. Initially, the letters in the word are displayed represented by "_”.   For example, if the random word is "yellow”, the game initially displays "_ _ _ _ _ _”. Then, each turn, the player guesses a single letter that has yet to be guessed. If the letter is in the secret word, then the...

  • 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...

  • //SCROLL TO BOTTOM FOR WAYS TO GET A MEETING AND AN EXCEEDING var secretWord = "secretword"...

    //SCROLL TO BOTTOM FOR WAYS TO GET A MEETING AND AN EXCEEDING var secretWord = "secretword" function setup() { createCanvas(400, 400); background(220); } function draw() {    rect(100,150,100,70) text("Click to \nstart hangman",110,175)    rect(225,150,100,70) text("Click to \nguess letter",235,175)    } function mousePressed(){ if(mouseOnRect(100,150,100,70)){ //begin hangman game //create variable to hold secret word as an array split by letter //create variable to hold display word as an array of * or _ that takes the place of each letter //get the...

  • 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...

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