title: React Typescript: Access Variable with forEach
body: <p>I use a <code>forEach</code> to access each <code>string</code> in <code>countTargetOptions</code> which is an array of properties that I want to access for the <code>targetData</code> variable.</p>
  <p>How can I use <code>element</code> to get each <code>targetData</code> property? My code below shows incorrect syntax as it prints <code>undefined</code>.</p>
  <pre><code>const countTargetOptions = [
    &quot;count_targets&quot;,
    &quot;count_targets_excluded&quot;,
    &quot;count_targets_pending&quot;,
    &quot;count_targets_in_progress&quot;,
    &quot;count_targets_completed&quot;,
    &quot;count_targets_failed&quot;,
  ];
  
   countTargetOptions.forEach((element: string) =&gt;{
      console.log(targetData.element);
     });
  
  </code></pre>