How to increment or decrement for loop by more than one with JavaScript?

Sometimes, we want to increment or decrement for loop by more than one with JavaScript.

In this article, we’ll look at how to increment or decrement for loop by more than one with JavaScript.

How to increment or decrement for loop by more than one with JavaScript?

To increment or decrement for loop by more than one with JavaScript, we can increment with += or decrement with -=.

For instance, we write

for (let i = 0; i < myVar.length; i += 3) {
  //...
}

to increment i by 3 with i += 3.

Or we write

for (let i = myVar.length - 1; i >= 0; i -= 3) {
  //...
}

to decrement i by 3 with i -= 3.

Conclusion

To increment or decrement for loop by more than one with JavaScript, we can increment with += or decrement with -=.