hangman

Hangman
<!–
gallows = new Array(“——–n| |n|n|n|n|n=====”,
“——–n| On|n|n|n|n=====”,
“——–n| On| |n|n|n|n=====”,
“——–n| On| \|n|n|n|n=====”,
“——–n| On| \|/n|n|n|n=====”,
“——–n| On| \|/n| |n|n|n=====”,
“——–n| On| \|/n| |n| /n|n=====”,
“——–n| On| \|/n| |n| / \n|n=====”)
guessChoices = new
Array(“joyfully”,”Outrageous”,”mysterious”)
function startAgain() {
guesses = 0
max = gallows.length-1
guessed = ” ”
len = guessChoices.length – 1
toGuess = guessChoices[Math.round(len*Math.random())].toUpperCase()
displayHangman()
displayToGuess()
displayGuessed()
}
function stayAway() {
document.game.elements[3].focus()
alert(“Don’t mess with this form element!”)
}
function displayHangman() {
document.game.status.value=gallows[guesses]
}
function displayToGuess() {
pattern=””
for(i=0;i<toGuess.length;++i) {
if(guessed.indexOf(toGuess.charAt(i)) != -1)
pattern += (toGuess.charAt(i)+” “)
else pattern += “_ ”
}
document.game.toGuess.value=pattern
}
function displayGuessed() {
document.game.guessed.value=guessed
}
function badGuess(s) {
if(toGuess.indexOf(s) == -1) return true
return false
}
function winner() {
for(i=0;i= max){
alert(“You’re dead. The word you missed was “+toGuess+”.”)
startAgain()
}
if(winner()) {
(window.confirm(‘Congrats! You Won!! Click OK to Continue. Cancel will load this website ‘))
{
window.location.href=’https://sandycreekmanor.weebly.com/announcements.html&#8217;;
};
startAgain()
}
}
// –>

Hangman


Word to guess
Letters guessed so far

Enter your next guess.