Here's how to build a list of the numbers from 1 to 101 in TypeScript:
index.ts142 chars8 lines
We start by declaring an empty array called numbers
that will hold our list of numbers. Then we use a for
loop that starts at 1 and increments up to 101. Inside the loop, we use the push()
method to add each number to the numbers
array. Finally, we log the resulting array to the console.
This will produce the following output:
index.ts25 chars2 lines
gistlibby LogSnag