title: Creating objects and storing them in an array
body: <p>I'm very new to Javascript, and what I'm about to ask is probably very rudimentary, but I'm stuck on a project, and I'd like some help.</p>
  
  <p>Basically I'm doing a small Javascript project, where I want there to be some enemies. In the beginning there will be 0 enemies, and then as time goes on, there might be created more enemies. I was thinking that whenever an enemy is created, I should create it as an object, and then store it in an array containing all the active enemies in game. Then, later on, I could remove enemies from the array, that  needed to be removed.</p>
  
  <p>This is the function that creates my enemy objects:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function enemy(name, strength, rarity, estTime, success, remTime, Id){
   this.name = name;
   this.strength = strength;
   this.rarity = rarity;
   this.estTime = estTime;
   this.success = success;
   this.remTime = remTime;
   this.Id = Id;
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>So, I could then create some enemies like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var enemy1 = new enemy("Bob", 1, "Common", 100, 1, 30, 1)
  var enemy2 = new enemy("Cow", 22, "Rare", 50, 10, 40, 2)
  var enemy3 = new enemy("Pig", 333, "Epic", 25, 10, 50, 3)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Then I could create an array of enemies, and put my 3 enemies into that array:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var enemies = [];
  enemies = [enemy1, enemy2, enemy3];</code></pre>
  </div>
  </div>
  </p>
  
  <p>All fine and dandy when I'm doing this manually, but the problem emerges when I want to try to get the code to automatically create some more enemies.
  Say I wanted to create an enemy everytime a button was pushed by the user. The name enemy would get some name, strength, rarity whatever, and the next Id in line (in this case 1, 2 and 3 are being used, so the next would be 4).
  I was thinking I could do it something like this, but this doesn't work:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>enemy[enemies.length + 1] = new enemy("Dog", 444, "Epic", 13, 100, 60, 4);
  enemies.push(enemy + [enemies.length + 1]);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I was hoping that this would create an object called "enemy4" with with name, id and whatever I just typed in, and then add that object to the array of enemies.</p>
  
  <p>But this obviously doesn't work. I hope you guys understand the problem, and any help is greatly appreciated. I realize that I'm probably just approaching this all wrong, and that there probably exists a much simpler way to do this.</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT: Yep, answer was very simple, got it now. Thanks!</strong></p>