Question: In HTML / JS , how do you stop multiple guesses of the same letter? Stop / disable the guesses button, and have a dialog

In HTML/ JS, how do you stop multiple guesses of the same letter? Stop/disable the guesses button, and have a dialog/ pop-up for losing and winning (it Should be in the updatePage()). ;)...
var POSSIBLE_WORDS =["obdurate", "verisimilitude", "defenestrate", "obsequious", "dissonant", "toady", "idempotent"];
var word ="";
var guesses ="";
var MAX_GUESSES =6;
var guessCount;
function newGame(){
guessCount = MAX_GUESSES;
guesses ="";
var randomIndex = parseInt(Math.random()* POSSIBLE_WORDS.length);
word = POSSIBLE_WORDS[randomIndex];
updatePage();
}
function updatePage(){
//update the clueString
var clueString =""; //This will be the var that holds the current _ or letters
for (var i =0; i word.length; i++){
var currentLetter = word[i];
if (guesses.indexOf(currentLetter)>=0){
clueString += currentLetter +""
}
else {
clueString +="_";
}
}
var clue = document.getElementById("clue");
clue.innerHTML = clueString;
//update the bank
var guessArea = document.getElementById("guesses");
guessArea.innerHTML = guesses
guessBox.value ="";
//update the picture
var image = document.getElementById("hangmanpic");
image.src = "img/hangman"+ guessCount +".gif";
}
function guessLetter(){
var input = document.getElementById("guess");
var letter = input.value;
if (word.indexOf(letter)0){
guessCount--;
}
input.value ="";//emtpy box
guesses += letter;
updatePage();
}
In HTML / JS , how do you stop multiple guesses

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!