I can't get this for loop to change the 0 to a 1. I need it to count to 30 by 5s. I would appreciate any help. Here is the code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I can't get this for loop to change the 0 to a 1. I need it to count to 30 by 5s. I would appreciate any help. Here is the code.

<!DOCTYPE html> <html> <head> <title>Page Title Goes Here</title> <meta charset="utf-8" /> <!-- template.html - reusable HTML template Thomas E. Weber - thomas.weber@my.southcentral.edu Written: --> <script> function getEkgLoop() { for(i=0; i <= 30; i++) { if(i%5 === 1) { document.write(i + "<br />"); } } } </script> <style> body { font-family: optima, helvetica, arial, sans-serif; } h1 { color: #000080; /* drak blue RRGGBB */ border: 1px solid #000080; background: #CECECE; /* light gray */ padding: 10px; /* space between text and border */ text-align: center; font-family: helvetica, arial, sans-serif; margin: 20px 0px; /* space between border and the other objects */ } </style> </head> <body> <script> getEkgLoop(); </script> </body> </html>

13th Oct 2016, 12:26 AM
Thomas Weber
Thomas Weber - avatar
2 Answers
0
You should call function every 5s, with setInterval()
13th Oct 2016, 12:34 AM
Dušan Sklopić
Dušan Sklopić - avatar
0
I thought about that, but my specs say to use the mod operator in a for loop.
13th Oct 2016, 12:51 AM
Thomas Weber
Thomas Weber - avatar