title: How to loop through an array and calculate the sum using angular rxjs
body: <p>const activityDetails = [</p>
  
  <pre><code>{
      username: "Tester",
  
      pointDetails: [
  
          {
              points: 4826,
              pointType: "BONUS"
          },
          {
              points: 9652,
              pointType: "BASE"
          },
          {
              points: 14478,
              pointType: "CLS"
          }
      ]
  },
  {
      username: "Tester2",
      pointDetails: [
          {
              points: 1126,
              pointType: "BONUS"
          },
          {
              points: 9652,
              pointType: "BASE"
          },
          {
              points: 44566,
              pointType: "CLS"
          }
      ]
  }
  </code></pre>
  
  <p>]</p>
  
  <p>Below is the code which i am trying to iterate over the array and count the point of BONUS and BASE. Am i missing something or is there any better way to iterate through the array and count the number? thanks</p>
  
  <pre><code>activityDetails.filter(n=&gt;{
         n.pointDetails.reduce((sum:any, rates:any) =&gt; {
       if (rates.pointType === "BONUS" || rates.pointType === "BASE") {
         sum+= rates.points;
         console.log(sum);
       }
  
     }, 0)
  
     })
  </code></pre>