title: Why is this forEach code snippet invalid in AngularJS?
body: <p>Here I have a generic calculation function.</p>
  <pre><code>private calculateTotal(order: InventoryOrder):number{
    let total = 0.0;
    if(order &amp;&amp; order.currentInventory){
      order.currentInventory.forEach(x =&gt;{
        console.log(x.quantity);
        console.log(&quot;helloworld&quot;);
      }  //error appears here&lt;- &quot;,&quot; expected.
    } return total;
  }
  </code></pre>
  <p>I tested very similar code at <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach</a></p>
  <pre><code>    const array1 = ['a', 'b', 'c'];
      
      array1.forEach(element =&gt; {
                      console.log(element);
                      console.log(&quot;helloworld&quot;);
                                });
  
  // expected output: &quot;a&quot;
  // expected output: &quot;b&quot;
  // expected output: &quot;c&quot;
  </code></pre>
  <p>Any idea what's going on?</p>