title: color td based on object field value Angular 6
body: <p>I have a table, and I want based on a property, to color rows like this:
  If <code>account</code> is the same, color them with gray, and if not, color them with blue. Here is my code:</p>
  
  <pre><code>func() {
      for (let i = 0; i &lt; this.List.length; i++) {
        if (this.List[i].account == this.List[i + 1].account) {
          this.List[i].color = "#f2f3f4"
        } else {
          if (this.List[i].account != this.List[i + 1].account &amp;&amp; this.List[i].color != "#f2f3f4") {
            this.List[i].color = "rgba(173, 216, 230, 0.35)"
          }
        }
      }
    }
  </code></pre>
  
  <p>but it's not working properly. How can I modify the code? <a href="https://stackblitz.com/edit/angular-q9siga" rel="nofollow noreferrer">Here is a working blitzstack</a></p>
  
  <p>I also get this error: (I guess it's from <code>List[i + 1]</code>)</p>
  
  <blockquote>
    <p>ERROR Error: Cannot read property 'account' of undefined</p>
  </blockquote>