-3

I want to detect if a number is dividable by 100 in NodeJS. How can I do this?

stijnb1234
  • 184
  • 4
  • 19

1 Answers1

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