title: JavaScript increase/decrease values in Hangman
body: <p>I am making a Hangman game in JavaScript, HTML, and CSS. I am stuck on trying to get the wins variable to increase by 1 after all the letters have been guessed correctly and have the guesses decrease by 1 after each letter is guessed.</p>
  
  <p>I also think that I need to incorporate this line of code but everywhere I try to insert it, the game breaks:</p>
  
  <pre><code>// Set the inner HTML contents of the #game div to our html string
      document.querySelector(".container").innerHTML = html;
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>//Array of available words
      const words = ["patriots", "bills", "dolphins", "jets", "chiefs", "chargers", "raiders", "broncos", "steelers", "ravens", "bengals", "browns", "jaguars", "titans", "colts", "texans", "eagles", "cowboys", "redskins", "giants", "rams", "seahawks", "cardinals", "niners", "vikings", "lions", "packers", "bears", "saints", "panthers", "falcons", "buccaneers"];
  
     let currentWord;
     let dashes = [];
     let rightLetter = [];
     let wrongLetter = [];
  
  // Creating variables to hold the number of wins and guesses remaining
      let wins = 0;
      let guesses = 10;
  
  // Creating a variable to hold our new HTML. Our HTML now keeps track of the user and computer guesses, and wins/losses/ties.
      let html =
      "&lt;p&gt;wins: " + wins + "&lt;/p&gt;" +
      "&lt;p&gt;guesses: " + guesses + "&lt;/p&gt;";
  
  
  
  //Click button to start game
      document.getElementById("start").addEventListener("click",function(){
          startGame("")
      })
  
  //Computer chooses a random word from the words array. The random choice becomes currentWord
      function startGame(){
          currentWord = words[Math.floor(Math.random() * words.length)];
  
  
  //Creates underscores depending on length of the currentWord; push underscores to dashes array 
          for ( let i = 0; i &lt; currentWord.length; i++ ) {
              dashes.push(' _ ');
  
  
          }
  
          writeWordDashes(dashes.join(' '))
      }
  
      function writeWordDashes(str){
          document.querySelector("#dashContainer").innerHTML = str;
      }
  
  
  //HTML document waits for key to be pressed; key is assiged Unicode value (a/A are diff)
          document.addEventListener('keypress', (event) =&gt; {
              let codes = event.keyCode;
  
  //Convert a Unicode value into a character
              let characters = String.fromCharCode(codes);
  
  //Search currentWord for the users correct guess; push character to rightLetter array
              if(currentWord.indexOf(characters) &gt; -1)
              rightLetter.push(characters);
  
  
  //Replace dashes with correctly choosen characters
              dashes[currentWord.indexOf(characters)] = characters;
  
  //Loop over word and replace dashes
              for( let i = 0; i &lt; currentWord.length; i++) {
                  let currentLetter = currentWord[i];
              if (currentLetter === characters) {
                  dashes[i] = characters;
              }
          }
  
  //Write words to dashes
              writeWordDashes (dashes.join(''))
  
  
  //Search currentWord for the users incorrect guess; push character to wrongLetter array
              if(currentWord.indexOf(characters) &lt; 0)
              wrongLetter.push(characters);
  
              document.querySelector(".wrong").innerHTML = wrongLetter;   
              })
  </code></pre>