In my quest to find a way to loop through an array a specific number of times using the for..of
function in TypeScript, I have come across numerous explanations for JavaScript, but none that directly address my question. Here is an example:
const someArray = [1, 2, 3, 4, 5, 6, 7];
for(let i of someArray) {
console.log(i);
}
//loop result are from 1 to 7
//i would like the loop to run 3 times so expected result to be 1, 2, 3
I am specifically interested in limiting this loop to only 3 iterations
and implementing it within the for...of
construct in TypeScript.
My understanding of TypeScript is still developing, and I appreciate any guidance on this topic.