I am new to javascript and am trying to make a Hangman game. I am at the point where a for loop checks the users input and if it matches, it should replace one of the underscores that is generated. How do I have the user input(ex: a or d) replace one of the underscores? I've tried splicing, and using the .replace method. Here is the fiddle: https://jsfiddle.net/jtpsj5eu/18/
Here is the loop in question:
for (i = 0; i < hangv.input.length; i++) {
//if user's guess is matched against one of the letters of the word, this will execute.
if (guess == hangv.input[i]) {
//replace underscores with guessed letter
newStr = guessa.slice(hangv.input[i], hangv.input[i]) + guess + guessa.slice(hangv.input[i] + 1);
console.log(newStr);
} else {
console.log("false");
}
}