sadmicrowave sadmicrowave -4 years ago 167
Javascript Question

Find if variable is divisible by 2

How do I figure out if a variable is divisible by 2? Furthermore I need do a function if it is and do a different function if it is not.

Answer Source

Use modulus:

// Will evaluate to true if the variable is divisible by 2
variable % 2 === 0  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download