I have made a word guessing game and I need a way to have a limit for the number of times someone can guess the word.
-
I need to use
&&
to check if the two Boolean conditions are true -
A variable needs to be added to track the players’ number of guesses
Here is where that code should be because this is that part of code that get players input
//Code below shows player's progress
alert(answerArray.join(""));
//Lines of code below is for getting a guess from the player, lowercasing and limit of trys
var guess = prompt("Guess a letter, or click Cancel to stop playing.");
guess = guess.toLowerCase();
if (guess === null && ) {
//For exiting the game, if cancel is pressed
break;
} else if (guess.length !== 1) {
alert("Please enter a single letter.");
} else {
for (var j = 0; j < word.length; j++) {
if (word[j] === guess) {
answerArray[j] = guess;
remainingLetters--;
}
}
}
}