title: if /else condition inside foreach
body: <p>I am developing an angular project.
  I have a table file I want to compare each element with a data value if it is correct I will do statement else I will do another comportement but my problem is that even the data is correct it always fetches all the table and should access in the else for a very short time.
  How to avoid that, please.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>if (this.data) {
    this.imgNotFoundText = '';
    this.data.package.files.forEach(element =&gt; {
      i++;
      this.picture = '';
      if (element.name == this.data.properties.Name) {
        this.picture = 'picOne.png'
      }
      if (i == this.data.package.files.length &amp;&amp; this.picture == '') {
        this.picture = './../assets/img/notFound.jpg'
      }
    });
  }
  </code></pre>