title: javascript object method undefined
body: <p>So, i'm new to JS, and i have some problems with object methods.
  the method buy() in the building object prototype should do what i defined for it, but it says "Undefined".</p>
  
  <pre><code>var bitcoins=9000; //for example
  var bitcoinsps=0;
      function building(price, bps, name) {
      this.price = price;
      this.bps = bps;
      this.name = name;
      this.amount = 0;
  }
  building.prototype.buy = function buy() {
  
      if (bitcoins &gt;= building.price) {
          amount++;
          bitcoins -= price;
          price *= 1.15;
          bitcoinsps += bps;
      }
  };
  </code></pre>
  
  <p>NOTE: yes, i did create an instance.</p>
  
  <p>i tried "building.blabla" and "this.blabla" when calling the vars, but nothing happens. what is wrong?</p>
  
  <p>edit: my new code:</p>
  
  <pre><code>var bitcoins = 0;
  var bitcoinsps = 0;
  var build = new Array();
  
  function building(price, bps, name) {
      this.price = price;
      this.bps = bps;
      this.name = name;
      this.amount = 0;
  
  }
  building.prototype.buy = function() {
  
      if (bitcoins &gt;= building.price) {
          this.amount++;
          bitcoins -= this.price;
          this.price *= 1.15;
          bitcoinsps += this.bps;
      }
  };
      build[1] = new building(70, 1, "Junky laptop");
      build[2] = new building(300, 4, "Average PC");
      build[3] = new building(1000, 15, "Gaming PC");
      build[4] = new building(5000, 70, "Dedicated Hardware");
      build[5] = new building(24000, 300, "Small cluster computer");
      build[6] = new building(100000, 1000, "Medium cluster computer");
      build[7] = new building(500000, 4500, "Large cluster computer");
  </code></pre>