I want to detect if a number is dividable by 100 in NodeJS. How can I do this?
Asked
Active
Viewed 387 times
-3
-
2Possible duplicate of [javascript how to tell if one number is a multiple of another](https://stackoverflow.com/questions/7037926/javascript-how-to-tell-if-one-number-is-a-multiple-of-another) – Daniel A. White Feb 26 '19 at 15:05
-
@DanielA.White I'm asking for detecting a hundred, and not a multiple of another number, so I don't think it's a duplicate. – stijnb1234 Feb 26 '19 at 15:12
-
detecting a hundred is asking for a multiple of a hundred. – Daniel A. White Feb 26 '19 at 15:12
-
The answer and the fact that it was accepted confirm the proposed duplicate. – Yunnosch Mar 05 '20 at 20:32
1 Answers
2
you can check reminder of the division by 100, if it is 0, then number ends with 00
like this:
console.log(1 % 100 == 0); // false
console.log(100 % 100 == 0); // true
console.log(101 % 100 == 0); // false
console.log(200 % 100 == 0); // true
console.log(1000 % 100 == 0); // true

Iłya Bursov
- 23,342
- 4
- 33
- 57