title: How to sum the properties of an object in typescript?
body: <p>I've got an object with properties and i want to calculate the time spent and total cost of all the items in the object.</p>
  <pre><code>[{giftFor: &quot;Adrian&quot;, giftName: &quot;mug&quot;, timeSpentOn: 20, cost: 6},
  {giftFor: &quot;Tanaka&quot;, giftName: &quot;baseball&quot;, timeSpentOn: 17, cost: 45},
  {giftFor: &quot;Jimmy&quot;, giftName: &quot;watch&quot;, timeSpentOn: 23, cost: 35},
  {giftFor: &quot;Brian&quot;, giftName: &quot;diary&quot;, timeSpentOn: 8, cost: 43},
  {giftFor: &quot;Bob&quot;, giftName: &quot;jeans&quot;, timeSpentOn: 13, cost: 32}]
  </code></pre>
  <p>I tried the method below but i got the error, &quot;Property 'map' does not exist on type 'ExpensesBreakDown'.&quot;</p>
  <pre><code>   calculateExpenses(itemArray: ExpensesBreakDown ) {
      let cost: number = itemArray
          .map((a) =&gt; a.cost)
          .reduce(function (a, b) {
              return a + b;
          });
  }
  </code></pre>
  <p>I defined Expensesbreakdown as a class</p>
  <pre><code>class ExpensesBreakDown {
      giftFor: string;
      giftName: string;
      timeSpentOn: number;
      cost: number;
  }
  </code></pre>
  <p>How can i go about this? I've just started on software development and Angular so please correct my rookie mistakes</p>