title: Prototypal inheritance javascript using variables in different functions
body: <p>I am making a Hangman game to improve my knowledge of prototypal inheritance.</p>
  
  <p>I am completely confused as to why on of the variables <code>this.guesses</code> is not visible in the prototypal functions. I have tried to play around with every different combination I could think of.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>function Hangman () {
      this.token;
      this.guesses = 7;
  }
  
  Hangman.prototype.startGame = function() {
      $.ajax({
              url:"http://hangman-api.herokuapp.com/hangman",
              type: "POST",
              data: {}
          }).done(function(data) {
              console.log(data);
              Hangman.token = data.token;
              $(".hangman-word").text(data.hangman);
          }).fail(function() {
          alert( "error" );
      });
  };
  
  Hangman.prototype.takeGuess = function(token, letter){
      var letter = $("#letter").val();
      $.ajax({
          url:"http://hangman-api.herokuapp.com/hangman",
          type:"PUT",
          data: {"token": Hangman.token, "letter": letter }
      }).done(function(data) {
              Hangman.guesses = Hangman.guesses - 1;
              console.log(Hangman.guesses)
          }).fail(function() {
          alert( "error" );
      });
          console.log(Hangman.token);     
  }
  
  
  var hangman = new Hangman;
  hangman.startGame();
  </code></pre>
  
  <p>The really strange thing is that <code>Hangman.token</code> is visible in the <code>takeGuess</code> function but <code>Hangman.guesses</code> is not. Can anyone explain why this is happening?</p>