问题描述:

This question already has an answer here:

Javascript run a function inside a loop every x iterations

5 answers

You could...

- Increment
`i`

by 3, not 1 - Use
`Modulo`

to check

So

```
for (i = 0; i < 5000; i=i+3) {
...
}
```

Or

```
for (i = 0; i < 5000; i++) {
// When i == 3, == 6, == 9 etc.
if (i % 3 == 0) {
trigger();
}
}
```

Use the modulo operator:

```
if (i % 3 === 0) ...
```

condition is true when `i`

is 0, 3, 6, ...