create a loop between 1 and 100 in javascript

To create a loop between 1 and 100 in javascript, you can use a for loop. The for loop allows you to specify the starting point, the condition for continuing the loop, and how to increment the loop counter.

Here's an example of how to create this loop:

index.tsx
for(let i = 1; i <= 100; i++){
  console.log(i);
}
51 chars
4 lines

In this code, we initialize the loop counter (i) to 1. The loop will continue as long as the value of i is less than or equal to 100. We then specify that i should be incremented by 1 at the end of each iteration.

Inside the loop, we're using console.log() to output the value of i to the console. This will print out the numbers 1 through 100.

You can modify the code inside the loop to do whatever you need to with the numbers, but the basic structure of the loop will remain the same.

related categories

gistlibby LogSnag