title: Combining two arrays side by side in Angular 7
body: <p>To combine two arrays side by side, I am following the below procedure but I get </p>
  
  <blockquote>
    <p>Cannot set Property "account" of undefined.</p>
  </blockquote>
  
  <p>Here is my code</p>
  
  <pre><code>    acs = [
      {
          "account": "Cash In Hand",
          "liabilities": 0,
          "assets": 8031597
      },
      {
          "account": "Tax Acs",
          "liabilities": 988363.72,
          "assets": 0.98
      },
      {
          "account": "Sundry Debtor",
          "liabilities": 0,
          "assets": 551
      },
      {
          "account": "Sundry Creditor",
          "liabilities": 0,
          "assets": 0
      }
  ];
  
  acd: any;
  acc: any;
  newacc: any;
  
  constructor() { }
  
  ngOnInit() {
      this.acd = this.acs.filter(f =&gt; f.liabilities !== 0);
      this.acc = this.acs.filter(f =&gt; f.assets !== 0);
  
      const bigger = this.acd.length &gt; this.acc.length ? this.acd.length : this.acc.length;
  
      this.newacc = [];
      for (let i = 0; i &lt; bigger; i++) {
        if (this.acd.length &gt; i) {
          this.newacc[i].account = this.acd[i].account;
          this.newacc[i].liabilities = this.acd[i].liabilities;
        }
        if (this.acc.length &gt; i) {
          this.newacc[i].accounts = this.acc[i].account;
          this.newacc[i].assets = this.acc[i].assets;
        }
      }
    }
  </code></pre>
  
  <p>If I add like this <code>this.newacc = [{}];</code> I get same error for 2nd <code>if</code> that is <code>this.newacc[i].accounts</code></p>
  
  <p>What I did mistake here? Or is there any easiest way to combine two arrays side by side? These two arrays are independent in array length and do not carry any join.</p>