print the numbers from 1 to 100, but only print the even numbers in typescript

index.ts
for (let i = 1; i <= 100; i++) {
  if (i % 2 === 0) {
    console.log(i);
  }
}
80 chars
6 lines

In this code block, we use a for loop to iterate from 1 to 100. Then we use an if statement with the modulo operator to check if the current number is even (i.e., it has no remainder when divided by 2). If the number is even, we print it to the console.

gistlibby LogSnag