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

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -