title: Uncaught type error: String is not a function only after second function call
body: <p>I'm trying to make a simple shopping cart in js (just for show). I made a function to store objects in the cart, and each button will pass args to an "add to cart" function that makes a <code>CartItem</code> object with the parameters and stores than in the <code>cart</code> array. It works great the first time, but I get the <code>Uncaught type error: String is not a function</code> on the following line: <code>var a = new CartItem(title, price);</code></p>
  
  <p>Here's the relevant js:</p>
  
  <pre><code>var cart = [];
  function CartItem(title, price) {
      this.title = title;
      this.price = price;
      this.getTitle = function() {
          return this.title;
      };
      this.getPrice = function() {
          return this.price;
      };
  }
  
  function addToCart(title, price) {
      var a = new CartItem(title, price);
      cart.push(a);
      /* update cart display */
      for (CartItem in cart) {
          var itemDiv = document.createElement("div");
          itemDiv.className = "cartItem";
          itemDiv.innerHTML = title + " - $" + price;
          document.getElementById("cartDisplay").appendChild(itemDiv);
      }
  }
  </code></pre>
  
  <p>and html:</p>
  
  <pre><code>        &lt;div class="cartDisplay" id="cartDisplay"&gt;
              &lt;p&gt;All photographs are printed on 11"x17" Fujitsu Archival Quality stock.&lt;/p&gt;
              &lt;h3&gt;Your Cart&lt;/h3&gt;
          &lt;/div&gt;
          &lt;div class="storeGrid"&gt;
              &lt;div class="storeItem"&gt;
                  &lt;img src="res/Photos/O_IMG_0002.jpg" class="storeImg"/&gt;
                  &lt;div class="storeItemDesc"&gt;
                      &lt;p&gt;Price: $300&lt;/p&gt;
                      &lt;p&gt;Description goes here.&lt;/p&gt;
                      &lt;a href="javascript:addToCart('Street with Steeple', 300, 1);" class="addToCart"&gt;&lt;div class="addToCartDiv" id="1"&gt;Add to cart
                          &lt;i class="fa fa-shopping-cart"&gt;&lt;/i&gt;&lt;/div&gt;&lt;/a&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>