title: Sum element is array returning wrong value
body: <p>I have a switch button called Today and yesterday. I have an array of values. When I click today it should sum the array values in today and when I click yesterday it should add today and yesterday value and display. </p>
  
  <p>I am facing a problem, that I stated below</p>
  
  <pre><code>public val1;
  public val2;
  public val3;
  public val4;
  data = [];
  
  if (value == 'a') {
    val1 = arr.reduce((acc, cur) =&gt; acc + Number(cur)); // add values inside 
    array
  } else if (value == 'b') {
    val2 = arr.reduce((acc, cur) =&gt; acc + Number(cur));
  } else if (value == 'c') {
    val3 = arr.reduce((acc, cur) =&gt; acc + Number(cur));
  } else if (value == 'd') {
    val4 = arr.reduce((acc, cur) =&gt; acc + Number(cur));
  }
  this.data.push(this.val1, this.val2, this.val3, this.val4);
  </code></pre>
  
  <p><strong>finally</strong></p>
  
  <p><code>arr = [5, undefined, 5,5]</code>
  <code>arr = [15,10,25,10]</code></p>
  
  <p>When I click today, Its showing <code>[5, undefined, 5,5]</code> which is correct
  When I click yesterday, Its Showing <code>[20,10,30,15]</code> (today + yesterday) which is correct. When I click <strong>today</strong> again its showing  <code>[5, 10, 5,5]</code> // 10 got append from the previous array but other values don't. My expected o/p is  <code>[5, undefined, 5,5]</code>.</p>