title: "TypeError: s.sum is not a function" an attempt to count sum property values of javascript object
body: <p>I have an js object JSON</p>
  
  <pre><code>var s = [  
     {  
        "MONTH":"  2018-01",
        "DEPARTMENT":"Legals",
        "EMPLOYEE":"Smith A.",
        "AMOUNT":"14289.66"
     },
     {  
        "MONTH":"  2018-01",
        "DEPARTMENT":"Legals",
        "EMPLOYEE":"Jonson B.",
        "AMOUNT":"7408.05"
     },
     {  
        "MONTH":"  2018-01",
        "DEPARTMENT":"Legals",
        "EMPLOYEE":"Lee C.",
        "AMOUNT":"10102.98"
     }
  ]
  </code></pre>
  
  <p>I want to count summ of AMOUNT property and do it by using next (I used code from source <a href="https://stackoverflow.com/questions/23247859/better-way-to-sum-a-property-value-in-an-array">stackoverflow_count_summ</a>):</p>
  
  <pre><code>s.sum = function(items, prop){
      return items.reduce( function(a, b){
          return a + b[prop];
      }, 0);
  };
  
  sTotal = s.sum(s, 'AMOUNT');
  </code></pre>
  
  <p>but I get an error message: "TypeError: s.sum is not a function"</p>
  
  <p>How can I get summ of 'AMOUNT' values through the object?</p>