create an array for looping typescript 1

create an array for looping typescript

loopTimes: number[] = Array(31);

for (let x = 0; x < loopTimes.length; x++) {
    console.log('Index/Loop No: ', [x]);
    // Do something here...
}

Here is what the above code is Doing:
1. We create an array with 31 elements.
2. We loop through the array and print the index of the current element.
3. We do something in the loop.

Similar Posts