title: Passing Object's Instance in Javascript
body: <p>Here is what I'm trying to do. I'm trying to pass an instance of order to bill, where it would be indexed. The thing is that it's not working. </p>
  
  <p>Am I stretching JS too thin here?</p>
  
  <p>Any example on how to do this, or some reading material?</p>
  
  <p>EDIT: Maybe I should add that this is supposed to be the user interface for a POS (Point of Sale) system. It should accept the order of products (each one with variable quantity), and process in the client's side the subtotal, total and number of items in the bill. </p>
  
  <p>EDIT2: Not native english speaker. Maybe the names that I choose did not best suited the problem.</p>
  
  <pre><code>function Bill (prefix,maxForms,minForms) {         
       this.prefix = prefix;
       this.maxForms = maxForms;
       this.minForms = minForms;
       this.items = [];
       this.total = 0;
  
       this.addOrder = function(order) {
           if (this.items.length == 0)
           {
               this.items.push(order);
           }
           for (i=0;i&lt;this.items.length;i++){
               if (this.items[i].name === order.name) {
                   this.items[i].quantity = order.quantity;
                   this.items[i].price = order.price;
               }
               else {
                   this.items.push(order);
               }
               this.total = this.total + order.getSubTotal();
           }
       }
   }
  
  
  
   function Order (name,price,quantity) {
  
       this.name = name;
       this.price = price;
       this.quantity = quantity;
  
       this.getSubtotal = function () {
           return this.price*this.quantity;
       }
       this.changeQuantity = function (newQuantity) {
           this.quantity = newQuantity;
       }
       this.incrementQuantity = function () {
           this.quantity = this.quantity + 1;
       }
   }
  </code></pre>