Could someone help me understand my issue? I have an array of a specific object, and I am trying to create a new array with just the values from a particular field in each object.
I attempted to use the forEach() method on the array, but I keep encountering a 'variable undefined' error within the function. Here is the code snippet:
var values: number[];
measures.forEach((measure)=>{
values.push(measure.value);
});
I've experimented with declaring the 'values' array as public (accessing it via this.values) and also declaring it within the function where the forEach loop is used, but neither approach fixed the issue.
When I run my code in the browser, I receive this error message (angular CLI does not show any problems):
ERROR TypeError: "values is undefined"