I use a forEach
to access each string
in countTargetOptions
which is an array of properties that I want to access for the targetData
variable.
How can I use element
to get each targetData
property? My code below shows incorrect syntax as it prints undefined
.
const countTargetOptions = [
"count_targets",
"count_targets_excluded",
"count_targets_pending",
"count_targets_in_progress",
"count_targets_completed",
"count_targets_failed",
];
countTargetOptions.forEach((element: string) =>{
console.log(targetData.element);
});