javascript - How to do something on each third for loop iteration -


this question has answer here:

how can alert on each third loop iteration alert ("some text") on each third iteration, how can make it?

for(var = 1; < 20; i++) {    alert("some text"); } 

use modulo operator (%):

for(var = 1; < 20; i++) {     if (i % 3 === 1) {         alert("some text");     } } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -