title: OO Javascript Game, how can i add players the game's player array?
body: <p>Here is the beginning of a very simple object oriented javascript game. I am having trouble adding players to the Games players[] array. how can this be done?</p>
  
  <p>i've removed all the code not relevant to the question</p>
  
  <pre><code>var BobsGame = function(){
  this.Players = [];
  }
  
  BobsGame.prototype.addPlayer = function(Player){
  //not working
  Player.Game = this;
  this.Players.push(Player);
  Player.setId = function(this.Players.length) {
      return this.Players.length;
  }
  return this;
  }
  
  var Player = function(name){
  this.Game = null;
  this.score = 0;
  this.name = name;
  this.id = null;
  //  return alert('Player ' + this.name + ' has been created');
  }
  
  var myGame = new BobsGame();
  
  var Player1 = new Player("Tom");
  var Player2 = new Player("Bob");
  
  myGame.addPlayer(Player1); 
  </code></pre>