I am creating a Hangman game and want to check whether a letter is in a string and if it is change that part of the word into the letter. My HTML:
<div id="word">
  <span id="letter_0"></span><span id="letter_1"></span><span id="letter_2"></span><span id="letter_3"></span><span id="letter_4"></span><span id="letter_5"></span><span id="letter_6"></span><span id="letter_7"></span><span id="letter_8"></span><span id="letter_9"></span>
</div>
Here is my javascript for the letter "a".
    function A(event) {
  for (var letter = 0; letter <= randomWord.length; letter++) {
    if (randomWord[letter] = "a") {
      document.getElementById("letter_" + letter).innerHTML = "A";
    }
  }
  if (event.target.classList.contains("disabled")) { 
    event.preventDefault();
  }
  document.getElementById("A").style.opacity = "0.5";
  event.target.classList.add("disabled");
  score = score + 1;
  document.getElementById("Score").innerHTML = score;
  }
The random word variable is a string randomly picked from a word list. Function A is an onClick event, and I will need to do the same for all the other functions, EG: function B(), C(), D().
Thanks
 
     
    