I'm struggling too much for this task. I need to make it; check to see if the word that i had written matches up to the word that is in the array. (single letter). if it does, it should replace the underscores with the characters that are in that word! How should I do it?
this is for a game like hangman btw This is my code:
<script>
var words = ["kite", "boom", "zoom", "tall", "table", "biscuit", "pie"];
window.addEventListener("load", function() {
var submitbtn = document.getElementById("button")
var userInput = document.getElementById("userInput");
submitbtn.addEventListener("click", checkAnswer, false);
var wordElt = document.getElementById("word");
var word = words[Math.floor(Math.random() * words.length)];
for ( var i=0; i < word.length; i++ ) {
//display += "_ ";
wordElt.textContent += " _ ";
}
var split = word.split("");
console.log(word)
});
function check(){
}