create an array from 1 to 100 in typescript

One way to create an array from 1 to 100 in TypeScript is to use a for loop to iterate from 1 to 100 and push each number to an empty array. Here is an example code snippet:

index.ts
const arr: number[] = [];

for(let i = 1; i <= 100; i++) {
  arr.push(i);
}

console.log(arr); // [1, 2, 3, ..., 100]
118 chars
8 lines

related categories

gistlibby LogSnag