index.tsx189 chars8 lines
In this code block, we initialize a variable called sum
to 0.
Then, we loop through all numbers from 1 to 100 using a for
loop.
Inside the loop, we use an if
statement to check if the current number is divisible by 3 or 5 using the modulo operator %
.
If it is divisible by 3 or 5, we add it to the sum
variable.
Finally, we use document.write()
to print the sum to the webpage, along with some text to make it readable.
gistlibby LogSnag