Reputation: 503
I think I have rather a simple question, I think...
I have this code
var resul = numCorrect+numIncorrect;
if (resul == 5){}
In place of 5 I want to have a multiple of 5 (5, 10, 15, 20) and so on. No 0!
I don't know how to express this in jquery. 5n doesn't work.
thanks in advance!
Upvotes: 0
Views: 425
Reputation: 579
The modulus operator (%) gives the remainder after a number is divided is divided. Multiples of five will always give a modulus of 0. So you just have to check the modulus and exclude zero
if ((resul%5 == 0) && (resul !=0)) {
//result is a multiple of 5
}
Upvotes: 0
Reputation: 82241
You can use operator %
:
if (resul && resul%5 == 0) {
//multiple of 5
}
Upvotes: 4