title: How to 'mask' a string or array?
body: <p>I've been asked to create a simple 'Hangman' for a Tafe assignment, but I've run into two issues.</p>
  
  <p>One is that the instructions ask me to 'mask' the word in an array so that it's easier to update as the player guesses letters, but I'm unsure how to do this.
  I currently have it so that the word is split and each of its letters saved into an array called letterArray as well as the full word save into toBeGuessed. I've reached the point where I have to update the ****** to look more like the word each time a letter is guessed.</p>
  
  <p>I found the following advice when looking over similar questions:</p>
  
  <blockquote>
    <p>Keep 2 copies of the string, the word and the obfuscated one (the one
    containing '-') (preferably as char array or string builder). When a
    user guesses a letter, search the non-obfuscated version for all
    instances of that letter. each time you find a match, change the '-'
    at that index in the obfuscated string to the correct letter.</p>
  </blockquote>
  
  <p>But I'm unsure how to do this. Would someone be able to point me in the right direction?</p>
  
  <p>The other issue I'm having is that every time I press 'play' all of the 'letters' become unclickable, but I can click on them before 'play' is clicked?
  I tried removing the 'play' button all together but then the letters won't respond at all.</p>
  
  <p><a href="http://www.codecademy.com/javaWhiz66294/codebits/ZUAsL6/edit" rel="nofollow">My current code</a> (it won't work on JSFiddle for some reason)</p>
  
  <h2>JS</h2>
  
  <pre><code>var listOfWords = ["aardvarks", "determine", "different", "greatness", "miserable", "trappings", "valuables", "xylophone"];
  var toBeGuessed = listOfWords[Math.floor(Math.random() * listOfWords.length)];
  var lettersArray = toBeGuessed.split('');
  var guesses = 0;
  var playerguess = 'dunno';
  
  $(document).ready(function() {
      $('#input').hide();
      $('#guessIt').hide();
      $('#play').click(function() {
          $('#theWord').html(toBeGuessed);
          for (var i = 1; i &lt; toBeGuessed.length + 1; i++) {
              $('#masked').append('* ');
          }
          $('#play').hide();
      });
      $('.letter').click(function() {
          value = this.value;
          guesses += 1;
          found = $.inArray(value, lettersArray) &gt; -1;
          if (found === true) {
              this.style.color = 'green';
          } else {
              this.style.color = 'red';
          }
          if (guesses === 5) {
              alert('Your five guesses are up! What do you think the word is?');
              $('#input').show();
              $('#guessIt').show();
          }
      });
      $('#guessIt').click(function() {        
              playerguess = document.getElementById("input").value.toLowerCase();
              if (playerguess === toBeGuessed) {
                  alert('Congrats! You win!');
              } else {
                  alert('I\'m sorry, but that\'s not correct. It was ' + toBeGuessed + '! You lose.');
                  $('#hangman').html('&lt;p&gt;___________&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(_)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /|\\ &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/ \\&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;br&gt;&amp;nbsp;&amp;nbsp;_|___&lt;/p&gt;');
              }
      });
  });
  </code></pre>
  
  <p>Any help would be appreciated!</p>