title: How to sum values in typescript array based on array items property?
body: <p>I'm working on small angular project. I have an array of receipt items, e.g. coke, fanta, pepsi, juice etc, with their prices and quantity of course.</p>
  
  <pre><code>receiptItems: Array&lt;ReceiptItem&gt;;
  </code></pre>
  
  <p>This is how <code>ReceiptItem</code> looks :</p>
  
  <pre><code>export class ReceiptItem {
  
    public id: string;
    public product: Product;
    public unitOfMeasure: UnitOfMeasure;
    public discount: number;
    public price: number;
    public quantity: number;
    public total: number;
    public tax:Tax;
  
   }
  </code></pre>
  
  <p>How can I in typescript get sum of total amount but only where property tax for example is equal to "25%"?</p>
  
  <p>In C# I remember I've used lambda expressions like this:</p>
  
  <pre><code>IEnumerable&lt;ReceiptItems&gt; results = receiptItems.Where(s =&gt; s.Tax == "25.00");
     totalSum = results.Sum(x =&gt; (x.TotalAmount));
  </code></pre>
  
  <p>How to achieve something similar in TypeScript / Angular?</p>