title: JavaScript sum function
body: <p>I have stacked in the sum of an array. The code is bellow</p>
  
  <pre><code>function User(name,email) {
          this.name = name;
          this.email = email;
          this.cartAmount = [];
          this.total = 0;
  }
  User.prototype = {
          constructor: User,
  
          addCart: function(mrp){
              this.cartAmount.push(mrp);
          },
  
          changeEmail: function(newmail){
              this.email = newmail;
          },
  
          showCart: function() {
              var cart = this.cartAmount.length &gt;0 ? this.cartAmount.join("tk,") : "No product in the cart";
              return this.name+" has "+cart+" in his cart.";
          },
  
          intotal: function(){
              for(var n in this.cartAmount){
                  this.total += this.cartAmount[n];
                  return this.total;
              }
          }
      };
      athar= new User("Athar Jamil", "atharjamil@gmail.com");
      console.log(athar.name);
      athar.changeEmail("atharjamil@yahoo.com");
      console.log(athar.email);
      athar.addCart(20);
      athar.addCart(50);
      athar.addCart(80);
      console.log(athar.intotal());
  </code></pre>
  
  <p>It shows me only 20 as the result of the sum. What is the problem?</p>