When attempting to loop through a string array in TypeScript, I encounter an error stating that foreach is not a function. What is the correct way to implement this in TypeScript?
Here is my code in main.ts:
content = ["renewal", "payments"]
If I use a for loop like this:
for (let i = 0, len = content.length; i < len; i++) {
console.log(content[i]);
}
It prints all the indexes [r e n e etc]. However, if I attempt to use forEach like this:
content.forEach(function(content){
console.log(content);
})
I receive an error indicating that content.forEach
is not a function.