To build a list of numbers from 1 to 100 in javascript, we can use a for loop to iterate from 1 to 100 and add each number to an array.
Here's the code:
index.tsx129 chars8 lines
In this code, we start with an empty array numbers
. We then use a for loop to iterate from 1 to 100 (inclusive) using the loop variable i
. Inside the loop, we add i
to the array using the .push()
method. After the loop finishes, we log the array to the console using console.log()
.
gistlibby LogSnag