title: How to take guess a word by its letter in js
body: <p>as the title says I'm making a little game, but it doesn't guess the word, I don't know why. I've added a word so people would have to guess it, using letters and if the letter is equal to any letter on the word it would replace the _.</p>
  
  <pre><code>&lt;!Doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Story&lt;/title&gt;
      &lt;style&gt;
          /*body {
              font-family: Calibri;
              font-size: 13.5pt;
              margin-left: 5px;
              color: black;
          }*/
  
          #aa{
              border: 1px solid black;
          }
  
          /*.in2{
              width: 300px;
              height: 630px;
              border: 0px solid white;
              background-color: white;
              color: white;
              font-family: Arial;
              font-size: 25pt;
          }*/
      &lt;/style&gt;
      &lt;script src="jquery-3.2.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          var word = "" //word variable
          var wLength = 0 //word length variable
          var dummy = "" //letter guessed
          var dm = new Array(26)
  
  
          $(document).ready(function(){
              $("input.in2").hide()
          })
  
          $(document).ready(function(){
              $("input.bi2").hide()
          })
  
          function doGetWord(){
              var word = F.gword.value;
              var wLength = word.length;
              for(var i = 0; i &lt; wLength; i++){
                  document.getElementById("dword").innerHTML += "_ "
              }
              $("input.wordi").hide()
              $("input.bi").hide()
              $("input.in2").show()
              $("input.bi2").show()
          }
  
          function doGuess(){
              dummy = F.t.value
              if(dummy.length &gt; 1){
                  dummy = ""
                  F.t.value = ""
              }
              else{
                  F.t.value = ""
                  alp = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
                  dd = dummy.toString()
                  window["cl" + dd]
                  if(window["cl" + dd] == false){
                      alert("Letter already used, please try again with another letter")
                      dummy = ""
                      F.t.value = ""
                  }
                  else{
                      window["cl" + dd] = false
                      F.t.value = ""
                      doGuessWord();
                  }
              }
          }
  
          function doGuessWord(){
              ws = new Array(wLength);
              for(i = 0; i &lt;= wLength; i++){
                  ws[i] = word.charAt(i)
                  if(dummy == ws[i]){
                      document.getElementById("dword").value.charAt(i) = dummy
                  }
              }
  
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form name="F"&gt;
          &lt;input type="text" name="gword" class="wordi"&gt;
          &lt;input type="text" name="t" class="in2"&gt;
          &lt;input type="button" name="b" value="do" onclick="doGetWord()" class="bi"&gt;
          &lt;input type="button" name="b2" value="do" onclick="doGuess()" class="bi2"&gt;
          &lt;div id="dword"&gt;&lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can you help me figure out what the error is? I just can't find it but I think it has something to do with the <code>document.getElementById("dword").value.charAt(i) = dummy</code>.
  Thanks in Advance!!</p>