Currently, I am on a mission to teach myself Javascript and have taken on the challenge of creating a simple hangman game. This type of project is commonly used in interviews or tests, so it seemed like a great opportunity for practice. My approach involves using Math.random to select a word from a list of options, then utilizing the prompt feature to guess the letters of the chosen word. However, I have hit a roadblock as I am struggling to get the prompt to recognize my input correctly. Any assistance you can provide would be greatly appreciated.
var secretWords = ["batman", "Donkey kong", "ninja", "programming"];
var chosenWord = secretWords[Math.floor(Math.random() * secretWords.length)];
var guesses = 8;
var letters = chosenWord.length
var guess = prompt("GUESS A LETTER");
alert(chosenWord);
for (var i = 0; i <= letters; i++) {
letters[i] = chosenWord.substring(i, i++)
}
if (guess = i) {
alert("nice")
} else {
alert("Wrong");
}