title: How do i reduce an array in Angular using a lambda statement?
body: <p>I have an object array <code>LeaveRequests[]</code> and a LeaveRequest has a field named totalHours. I'm trying to reduce this array to the sum of all totalHours fields.Then i'm assigning this to a numerical variable called <code>pendingLeaveHoursTotal</code></p>
  
  <p>Right now the code looks like this:</p>
  
  <pre><code>this.pendingLeaveHoursTotal = this.leaveRequests.reduce((a,b) =&gt; a.totalHours+b.totalHours,0)
  </code></pre>
  
  <p>Its using a lambda to do the sum work, however it gives a syntax error. My question is, is it possible to use a lambda statement or do I need to define a function first and add that as an argument to the reduce method together with a start number (in this case 0)?</p>