Sometimes, we want to use modulo operator (%) in JavaScript.
In this article, we’ll look at how to use modulo operator (%) in JavaScript.
How to use modulo operator (%) in JavaScript?
To use modulo operator (%) in JavaScript, we can use it to get the remainder when dividing a number by another.
For instance, we write
const remainder = 10 % 3;
to get the remainder when dividing 10 by 3.
remainder
should be 1 since 10 divided by 3 has remainder 1.
Conclusion
To use modulo operator (%) in JavaScript, we can use it to get the remainder when dividing a number by another.