I'm working on a function with a forEach loop and I need to keep track of how many times the loop is executed. Can anyone suggest a way to tweak my logic to achieve this?
Below is what I have tried so far:
createUIListElements(){
xml2js.parseString(this.xml, (err, result) => {
this.uiListElement = result['cm:property-placeholder']['cm:default-properties'][0]['UIInput'][0]['UIListElement']
console.log(this.uiListElement);
this.uiListElementArray = this.uiListElement.map((element: { $: any;}) => element.$);
let count = 0;
this.uiListElementArray.forEach((element: any) => {
count++;
this.createUIElementsList(count);
console.log(element);
})
})
}